jQuery 执行订单
我正在使用以下 jQuery 插件,它在指定元素上有单击操作时执行:
http ://www.andresvidal.com/labs/relcopy.html
我还为同一元素创建了一个点击函数,但我希望它在插件之后执行。但事实并非如此,点击函数总是首先执行,从而导致问题。
例如,请检查我下面的代码,我是 jQuery 新手,因此任何建议/帮助将不胜感激!
$.getScript('../js/relCopy.js', function() {
$('#AddTable').relCopy({
limit: 10,
excludeSelector: '.newListSelected'
});
$('#AddTable').click(function() {
do something here after relcopy has finished
});
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 code 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
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事件处理程序按照它们绑定的顺序执行,并且由于
$.getScript( )
在该脚本加载后执行,它在您的之后绑定它的点击
处理程序。因此,获取您想要的顺序,您需要按照您想要的顺序绑定,这意味着也在回调中绑定您的点击处理程序,如下所示:
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'sclick
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: