模拟点击“添加更多价值”多值 cck 字段的按钮导致整个内容表单提交
您好,我的 cck 内容类型中有一个多值 cck 字段。我想使用 jquery 模拟单击“添加另一个项目”。就像
$('#edit-field-supp-quan-field-supp-quan-add-more').trigger('click');
但它会导致整个内容表单提交,而不是添加额外的多值 cck 字段。
手动点击工作正常。谁能告诉我为什么手动点击和模拟点击的行为不同。 谢谢
----更新---- 这是我使用的代码:-
$('#edit-field-freightamount-0-value').click(function(){
alert('hello');
$('#edit-field-supp-quan- field-supp-quan-add-more').trigger('click');
//$('.form-submit ahah-processed').trigger('click')
;
我实际上打算从其他函数内部调用它,但我只是想在此之前测试它。所以我写了这个虚拟函数,就像如果我在 texrfield 内单击它应该模拟单击“添加更多项目”
我们如何防止单击的默认操作?
Hi I have a multi value cck field in my cck content type. I want to simulate click on "add another item" using jquery. which is like
$('#edit-field-supp-quan-field-supp-quan-add-more').trigger('click');
but it causes whole content form to submit instead of adding extra multi value cck field.
Manuall clicks are working perfectly. Can anyone tell me why behavior of manual clicks and simulated clicks are different.
thanks
----Update ----
This is the code I was using:-
$('#edit-field-freightamount-0-value').click(function(){
alert('hello');
$('#edit-field-supp-quan-field-supp-quan-add-more').trigger('click');
//$('.form-submit ahah-processed').trigger('click');
});
I actually intended to call this from inside some other function but I just wanted to test it before that . So i wrote this dummy function which is like if i click inside a texrfield it should simulate a click on "add more item"
How do we prevent default action of click?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有同样的问题。
答案很简单,使用 mousedown 而不是 click :)
had the same problem.
The answer is simple enough, use mousedown instead of click :)
尝试。
在点击功能结束时
Try
at the end of your click function.
更改
为
然后放入
单击处理程序函数。
Change
to
then put
in the click handler function.