0

I have some links in the homepage.

When any of the links are clicked, the new page is being shown. But, when we click the link, document.ready is not being called, so I have to either refresh or press enter on the address bar or copy address bar url and open in new window.

What to do so that when links clicked, document.ready will be called ?

Please let me know if I am not clear.

Some guys want me to put code here, so look at the below code:

$(document).ready(function(){
    console.log("doc ready");
});

This console is not being called. Thanks.

4

2 に答える 2

1

Ready ハンドラーは、呼び出されるとバインドが解除されます。この種のスニペットを使用する必要があります。

$(readyHandler);

function readyHandler(){
    //call on ready or trigger it manually!
}

$('#myLink').on('click',function(e){
    e.preventDefault();
    //depending your logic, if calling some ajax method as .load() method, use complete callback/success and recalled method:
    $('#dynamicContentElement').load('myUrl',readyHandler);
});
于 2013-09-10T09:15:42.417 に答える
0

ハイパーリンクのクリックに割り当てるだけです

$("a").click(function() {
  $(document).trigger("ready");
});
于 2013-09-10T09:10:31.223 に答える