重新启用通过disable_with禁用的链接 [英] Re-enable links disabled with disable_with
本文介绍了重新启用通过disable_with禁用的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何手动重新启用因Rails的 disable_with
功能而被禁用的链接(不是表单元素)?
How can I manually re-enable links (not form elements) that get disabled with Rails' disable_with
feature?
推荐答案
对重新启用链接的调用与表单元素略有不同.它实际上将处理程序绑定到click事件,以阻止其他事件的发生.通过研究如何jquery-ujs库.
The call to reenable links is slightly different than form elements. It actually binds a handler to the click event that stops anything else from happening. I was able to figure this out by investigating how the jquery-ujs library.
要恢复这种效果,只需在jQuery对象上使用 enableElement
方法:
To reverse this effect, simply use the enableElement
method on your jQuery object:
$.rails.enableElement($('a[data-disable-with]'));
使用Turbolinks,它还有助于监视'page:change'
事件,而不是 window.unload
:
$(document).on('page:change', function() {
$.rails.enableElement($('a[data-disable-with]'));
});
这篇关于重新启用通过disable_with禁用的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文