Jquery masked entry for uploaded content

So I have joomla! which is partially created by user-based functions. Thus, the parts of the forms that I need to use the "hidden input plug-in" are loaded through the page load functions. The problem is that in fields that are standard HTML on the page, the plugin works fine, but in fields that are generated by my php functions, the fields are blocked and do not allow input. I suppose the problem is that php functions are pulling forms after the jquery plugin is running, but I tried putting the .mask call in $ (document) .ready and no luck.

here is a fragment ...

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

THIS WORK β†’

 <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 DOES NOT GIVE β†’ this function β†’

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

loaded in this form β†’

 <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> 
+4
source share
3 answers

All you have to do is bind the event binding using jQuery.on, and any dynamically created element will be connected to this event.

I answered a similar question here fooobar.com/questions/876518 / ...

+5
source

I think since the content is loading dynamically, you need to use. live

I don't know how to use .live with .mask.

There is also an alternative. You can put .mask code in a dynamic load callback function.

 $("#dynamicContent").load("loadFromMe.php",function(){ $("#subNumber").mask("(999) 999-9999"); $(".numFix").mask("(999) 999-9999"); }); 
0
source

JQuery dynamic I / O matrix (swicth software masking)

 $(document).ready(function () { $("[data-mask]").inputmask(); // Do something exciting var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(function () { // re-bind your jQuery events here $("[data-mask]").inputmask(); }); }); if (is_loose == "True") { $("#it_qty").removeAttr("data-inputmask","'mask': '9{0,20}'"); $("#it_qty").attr("data-inputmask", "'mask': '9{0,20}.9{0,2}'"); $("[data-mask]").inputmask(); } else { $("#it_qty").removeAttr("data-inputmask", "'mask': '9{0,20}.9{0,2}'"); $("#it_qty").attr("data-inputmask", "'mask': '9{0,20}'"); $("[data-mask]").inputmask(); } 
0
source

Source: https://habr.com/ru/post/1379217/


All Articles