Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to bind click after unbind
    primarykey
    data
    text
    <p>I have problems trying to bind the click back to the button after I have unbind. </p> <p>The button will be unbind when there's is change event in the Code text field. The change will check if there are duplicate in the database. If the there are no duplicate, it will bind back click to the Save button but it's not working. </p> <p><strong>The jQuery Code</strong></p> <pre><code>$(document).ready(function() { $('#glaccountssomgr_save_btn').on('click', submitGLAccount); $('#glaccountssomgr_acount_code').change(function(event) { $('#glaccountssomgr_save_btn').off('click', submitGLAccount); var inputCode = $('#glaccountssomgr_acount_code').val(); $.ajax({ url: '&lt;?php echo Router::url(array('controller' =&gt; 'GeneralLedgerAccountsSOMgr', 'action' =&gt; 'glaCheckDuplicate', '')); ?&gt;', data: {code: inputCode}, type: 'POST', success:function(data) { if(data) { var dupResults = jQuery.parseJSON(data); if(dupResults.isDuplicate) { $('#glaccountssomgr_save_btn').off('click'); alert("The GL Account is already in use. Please use another Code"); $('#glaccountssomgr_acount_code').focus(); return false; } else { alert("No duplicate"); //the below does not get call $('#glaccountssomgr_save_btn').on('click', submitGLAccount); } } else { alert("Error in checking GL Account Code. Please try again"); return false; } }, error:function(data) { alert("Unexpected Error. Please try again"); } }); }); }); function submitGLAccount() { //performs validation checking and data submission alert("I'm here"); } </code></pre> <p><strong>The Save button</strong></p> <pre><code>&lt;a href="#" id="glaccountssomgr_save_btn" name="glaccountssomgr_save_btn" data- role="button" data-icon="check" data-inline="true" data-ajax="false" data-theme="b" data-iconpos="right"&gt;Save&lt;/a&gt; </code></pre> <p>The Save button will only re-bind again if it's being clicked twice if the focus goes from Code to other form elements. </p> <p>Am I doing something wrong? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload