开发者

jQuery plugin misunderstanding

I have loaded an array wih data out of an xml file. I know the data is in the array at the location of the code, since I use it. I am trying to initiate a plugin to preload images. I have not gotten that far yet. I am stuck on the fact that my plugin does not get fired. The weird thing is that when I incorporate the alert message alert('hello'), the data from my array gets pushed out 开发者_StackOverflow中文版the way I want. When I take it out, it does not work. I am reasonably new at this, but not a total noob .. It just doesn't make sense to me.

(function( $ ){
alert('hallo');
  $.fn.preload = function() {        
    this.each(function(){
                alert(this.children('name').text());

    });
}
})( jQuery );

$(photoArray).preload();

I am lost ... !


This script works fine. Make sure that the array that is submitted is filled with data.

The array is filled dynamically with data from an XML file. At the moment of making the call to the plugin, the array is not yet filled. The added alert holds the script for a moment, which is long enough for the array to be filled. Consequently the script does not parse data without the added delay from the alert, because there is no data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜