开发者

How do I find if an element has been loaded using JQuery

I am loading data into the flexigrid. I am trying to use JQuery selectors to make the rows clickable, but I am unable to do so. I want to know if the element has been fully loaded, how do I do that?

I want to do something like if(element.load == true){//do this}. I am not sure of how to check that out. Could anybody help me with this.

Ok, 开发者_运维百科so I already have this div, and am binding a flexigrid to that div. I want to know if the flexigrid has been bound.

$("#GridLoad").flexigrid();

I want to know if the flexigrid has been bound, after that, I need to run a piece of code.

Using a live() on div Gridload would always be true as it is already there. :(


I want to know if the element has been fully loaded?

There appears to be an onSuccess callback.

$("#GridLoad").flexigrid({
   'onSuccess': function() {
      // Do this.
   }
});

Otherwise, if the things you are binding are being lost when the table updates, attach the events via on() or simply capture them at the persistent ancestor element and examine event.target.


You can use $(element).live('click', function () { // do something });

so that if it later loads it'll have the appropriate event binding.


you could use the callback function of jquery's load method.

like so :
$('#result').load('ajax/test.html', function() {
alert('Load was performed.');
});

Even if you are not using 'load' method, almost any method in jquery supports callbacks which happen after the functionality has been completed.
For example, ajax() has success and failure callbacks, animations has callbacks, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜