jQuery屏蔽了已加载内容上的输入 [英] jquery masked input on loaded content

查看:90
本文介绍了jQuery屏蔽了已加载内容上的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个joomla!该页面部分由基于用户的功能生成.因此,我需要使用蒙版输入插件"的部分表单是通过页面加载中的函数加载的.我的问题是,在页面上的标准HTML字段上,插件可以正常工作,但在由我的php函数生成的字段上,该字段锁定并且不允许任何输入.我的猜测是,jQuery插件触发后,php函数将表单拉入表单是一个问题,但我尝试将.mask调用放在$(document).ready中,但没有运气.

So I have a joomla! page that is partly generated by functions based on the user. So parts of the forms that I need to use the 'masked input plug-in' on are loaded via functions on page load. The issue I have is, on the fields that are standard HTML on the page, the plugin works fine but on the fields that are generated by my php functions, the fields lock up and don't allow any input. My guess is that it's an issue with the php functions pulling in the forms after the jquery plugin has fired but I tried placing the .mask call in a $(document).ready and no luck.

这是一个片段...

jQuery(function($){
  $("#subNumber").mask("(999) 999-9999");
$(".numFix").mask("(999) 999-9999");
});

这项工作->

<form name = "subAct" id = "subAct" method="post">
<div class="col1"><input class="subaccountname" name="subName" type="text" id="subName"/></div>
<div class="col2"><input class="subaccountnumber" name="subNumber" type="text" id = "subNumber"/></div>
<div class="col3"><a href="javascript:submit()" class="buttonaddsub" id ="addSubBut">Add a New Account</a></div>
</form>

这不是-> 这个功能->

THIS ONE DOESN'T --> this function -->

<?php dashboardFunction::displaySubAccount($uid) ?>

以这种形式加载->

<form name = "add_reg_num_<?php echo $pin ?>" id = "add_reg_num_<?php echo $pin ?>" method="post">
<div class="regisnumberadd"><input name="regNum" type="text" class = "numFix" />
<input name="regNumPin" type="hidden" value = "<?php echo $pin ?>"/>
</div>
<div class="clear"></div>
<div class="addregisnum"><a href="javascript:;" onClick="subRegNum(<?php echo $pin ?>)">Add Number</a></div>
</form>

推荐答案

所有您需要做的就是使用jQuery .on方法附加事件绑定,任何动态创建的项目都将与该事件关联.

All you need to do is attach an event binding using jQuery .on method and any dynamically created item will be wired to that event.

我在这里 https://stackoverflow.com/a/10203361/12442

这篇关于jQuery屏蔽了已加载内容上的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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