calling a javascript function (in original function) from called function?

后端 未结 2 867
迷失自我
迷失自我 2021-01-26 12:56

Is there anyway to calling a function from another function .. little hard to explain. heres in example. One function loads html page and when ready it calls the original functi

2条回答
  •  耶瑟儿~
    2021-01-26 13:02

    I slightly changed the signature of your loadthis function aloowing it to be passed the order to actually load.

    I also assumed that your doSomeStuff function accepts a callback function. I assumed that it may be an AJAX call so this would be trivial to call a callback function at the end of the AJAX call. Comment this answer if you need more info on how to fire this callback function from your AJAX call.

    order.prototype.printMe = function(){
        order_resume.load(this, "myTestPage.html", "showData");
    }
    
    order.prototype.testme= function(){
         alert("i have been called");
    }
    
    //Then when in "loadthis" need to call 
    
    orderRsume.prototype.load = function(order, page, action){
        //  DO SOME STUFF AND WHEN LOADS IT ARRIVES IN OnReady
        doSomeStuff(page, action, function()
        {
            order.OnReady();
        });
    }
    
    order.prototype.OnReady= function(){
      /// NEED TO CALL ORIGINAL "testme" in other function
      this.testme();
    }
    

提交回复
热议问题