javascript - jQuery Masked Input plugin not working on form input? -
i'm trying use masked input plugin on 1 of datatables editor fields (#dte_field_phone). reason, mask isn't being applied code:
$('#dte_field_phone').mask('(999) 999-9999');
i'm calling mask after table , editor initialized, yet still nothing. ideas on may doing wrong?
html:
<div class="dte_field_input" data-dte-e="input"> <input id="dte_field_phone"></input> <div class="dte_field_error" data-dte-e="msg-error" style="display: none;"></div> <div class="dte_field_message" data-dte-e="msg-message"></div> <div class="dte_field_info" data-dte-e="msg-info"></div> </div>
jquery:
jquery(function ($) { $( document ).ready(function (e) { var editor = new $.fn.datatable.editor({ "ajaxurl": "../wp-content/plugins/contacts/php/table.wp_contacts.php", "domtable": "#form_results7", "fields": [ { "label": "contact", "name": "contact", "type": "text" }, { "label": "company", "name": "company", "type": "text" }, { "label": "email", "name": "email", "type": "text" }, { "label": "phone", "name": "phone", "type": "text" }, { "label": "fax", "name": "fax", "type": "text" }, { "label": "address", "name": "address", "type": "text" }, { "label": "tax id", "name": "tax_id", "type": "text" } ] }); $('#add_items').on('click', function (e) { e.preventdefault(); editor.create( 'add contact', { "label": "add", "fn": function () { editor.submit() } } ); }); $('#form_results7').on('click', 'a.editor_edit', function (e) { e.preventdefault(); editor.edit( $(this).parents('tr')[0], 'edit contact', { "label": "update", "fn": function () { editor.submit() } } ); }); $('#form_results7').on('click', 'a.editor_remove', function (e) { e.preventdefault(); editor.message( "are sure want remove row?" ); editor.remove( $(this).parents('tr')[0], 'delete row', { "label": "confirm", "fn": function () { this.submit(); } }); }); var otable = $('#form_results7').datatable({ "bautowidth": false, "bjqueryui": true, "sajaxsource": "../wp-content/plugins/contacts/php/table.wp_contacts.php", "sdom": "<'h'lfr>t<'f'ip>", "aocolumns": [ { "mdata": "contact", "swidth": "14%" }, { "mdata": "company", "swidth": "14%" }, { "mdata": "email", "swidth": "17%" }, { "mdata": "phone", "swidth": "11%" }, { "mdata": "fax", "swidth": "11%" }, { "mdata": "address", "swidth": "17%" }, { "mdata": "tax_id", "swidth": "8%" }, { "bsortable": false, "mdata": null, "sclass": "center", "sdefaultcontent": '<a href="" class="editor_edit">edit</a> | <a href="" class="editor_remove">delete</a>', "swidth": "8%" } ], "spaginationtype": "full_numbers" }); $('#dte_field_phone').mask("(999) 999-9999"); try {$("#form_results7_length select").msdropdown();} catch(e) {alert(e.message);} $('#refresh_items').click(function() { location.reload(); }); $("#reset").click(function() { $("#form_results7_filter input").val(""); otable.fnfilter(""); otable.fnsort([[ 0, "asc" ]]); }); }); });
i have no experience of datatables code think using popup editor? if need apply mask in event fired after editor opened this:
editor.on('onopen', function () { $('#dte_field_phone').mask('(999) 999-9999'); });
Comments
Post a Comment