Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a problem with triggering a function which needs to be loaded only one time.But I don't want to put it into:

jQuery(document).ready(function ($) {

});

I want to run it separate.

I have tried:

 jQuery(document).one(function () {
        myfunction();
    });

and some other stuff. But couldn't solve it.

UPDATE:

I have my webservice on ready():

jQuery(document).ready(function ($) {
    PageMethods.myWebSer(suc, fail);
});

function suc(){
//I want to run my function here , but only one time
//Examplle
 //jQuery(document).one(function () {
          //  myfunction();
       // });
}

Thank You

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
351 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just add another ready or load function : you may have as many as you want, they will all be called in order :

jQuery(document).ready(function() {
   // this will be run
});
jQuery(document).ready(function() {
   // and this one too (after the other one)
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...