把手表单提交不起作用 [英] Handlebars form submit does not work

查看:55
本文介绍了把手表单提交不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,在把手里面提交不起作用,我要做什么?任何人都可以帮忙吗?



 < script id =chat-window-templatetype =text / x -handlebars模板> < a href =#class =close>< i class =fa fa-times>< / i>< / a> < a href =#> < span class =pull-left> < img src ={{user_image}}width =40> < /跨度> < span class =contact-name> {{user}}< / span> < / A> < div class =panel-bodyid =chat-bill> < form id =messageForm> < input id =nameInputtype =hiddenclass =input-mediumvalue =Macbook/> < input id =messageInputtype =textclass =form-controlplaceholder =Digite uma mensagem .../> < input type =submitvalue =发送/> < /形式> < / div>< / script>  

  $(#messageForm)。submit(function(){alert();}); 


解决方案

也许在编译Dom之前附加了处理程序,试着听t body事件和按选择器过滤,应该监听将来添加的Dom节点...

  $(document.body ).on(submit,#messageForm,function(){alert();}); 


I have a form that within a handlebars put the submit does not work, I have to do? Can anyone help?

 <script id="chat-window-template" type="text/x-handlebars-template">
      <a href="#" class="close"><i class="fa fa-times"></i></a>
      <a href="#">
        <span class="pull-left">
        <img src="{{ user_image }}" width="40">
        </span>
        <span class="contact-name">{{user}}</span>
      </a>
    <div class="panel-body" id="chat-bill">	
	<form id="messageForm">
	   <input id="nameInput" type="hidden" class="input-medium" value="Macbook" />
	   <input id="messageInput" type="text" class="form-control" placeholder="Digite uma mensagem..." />
	   <input type="submit" value="Send" />
	</form>
   </div>
</script>

$("#messageForm").submit( function() {alert();});

解决方案

Perhaps handler is attached before Dom is compiled, try listening t body events, and filtering by selector, should listen to Dom nodes added in future too...

$(document.body).on("submit", "#messageForm", function() {alert();});

这篇关于把手表单提交不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆