0

Can't use a function from an external JavaScript file

asked 2020-11-13 23:58:44 +0800

Victorsilveira1 gravatar image Victorsilveira1
51

updated 2020-11-16 16:46:43 +0800

cor3000 gravatar image cor3000
5409 2 7
ZK Team

Hello, i'm creating a zul file from an existing html file, in this html i use an external js file, with jquery to animate the pages. When I created the zul file, the function of controll the scrolling wasn't working so i tried to create another zul to test the function, but it doesn't work unless i don't use the xmlns="http://www.w3.org/1999/xhtml" (i used the * because my karma is too low for links) namespace, how can i do it work? this is the js file:

scrollFunction = function(){
    var scrollPos = 0;
    var Counter = 0;
    $(window).scroll(function(){
        var scrollPosCur = $(this).scrollTop();
        if (scrollPosCur > scrollPos) {
            Counter -= 1;
        } else {
            Counter += 1;
        }
        scrollPos = scrollPosCur;
        console.log(scrollPosCur);
    });

}

$(document).ready(scrollFunction);
delete flag offensive retag edit

Comments

I increased your karma to allow posting links

cor3000 ( 2020-11-16 16:45:50 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-11-16 16:44:42 +0800

cor3000 gravatar image cor3000
5409 2 7
ZK Team

updated 2020-11-16 16:48:40 +0800

I added your script to a simple zul file and it "just works" in my case. I assume you're doing something more complicated than what I did in my test case: https://zkfiddle.org/sample/1rmfi2s/1-included-script

Can you adjust the example so it reproduces your problem (then save and provide the updated link)? If possible please provide some error information you are getting, in the browser console.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2020-11-13 23:58:44 +0800

Seen: 5 times

Last updated: Nov 16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More