I'm using the following jQuery plugin and it executes when there's a click action on the specified element :
http://www.andresvidal.com/labs/relcopy.html
I also created a click function for the same element, but I expected it to execute after the plugin. However that isn't the case, the click function always executes first, thus causing problems.
Please check my cod开发者_StackOverflow中文版e below for example, I'm new to jQuery so any suggestions / help would really be appreciated!
$.getScript('../js/relCopy.js', function() {
$('#AddTable').relCopy({
limit: 10,
excludeSelector: '.newListSelected'
});
$('#AddTable').click(function() {
do something here after relcopy has finished
});
Event handlers are executed in the order they were bound, and since the callback from $.getScript()
executes after that script is loaded, it's binding it's click
handler after yours.
So get the order you want you need to bind in the order you want, that means binding your click handler in the callback as well, like this:
$.getScript('../js/relCopy.js', function() {
$('#AddTable').relCopy({
limit: 10,
excludeSelector: '.newListSelected'
}).click(function() {
//do something here after relcopy has finished
});
});
精彩评论