【发布时间】:2016-03-15 18:19:43
【问题描述】:
我正在尝试将 ajax:beforeSend、ajax:error 和 ajax:complete 绑定到远程提交的 Rails 表单中。
我尝试使用委托、绑定、实时等,但我仍然面临同样的问题。
$('form#contact_form').bind('ajax:beforeSend', function(evt, xhr, settings) {
//getItemIds(); added this call on button click
call();
})
.bind('ajax:error', function(event, request, settings) {
text();
})
.bind('ajax:complete', function(event, request, settings) {
phone();
});
我在页面上还有其他锚链接,它们也进行 ajax 调用,但对于任何 ajax 调用,都会调用表单“beforesend”函数。我只想为那个特定的形式调用它。
当我做警报(event.target.id);在 ajaxBeforesend 中,我看到了一个我没有绑定 ajax 调用的元素的 id
I am targeting only a specific form so how that before send be triggered for other links? Can anyone tell what is that i am doing wrong, Thanks.
NOTE: When i commented out the jquery_ui.js this behaviour stopped happening. Is is some conflict issue, Please help.
【问题讨论】:
-
表单是动态的吗?
-
是的,它是 Rails 形式
标签: javascript jquery ajax ruby-on-rails-3 jquery-ui