Note that there are some explanatory texts on larger screens.

plurals
  1. POClick Event is not fired (or ignored) when performing an ajax call in the background that validates a form
    primarykey
    data
    text
    <p>I am validating an objects "name" to ensure it is unique. To perform this I am using the jQuery bassisstance validation plugin. I issue a SYNCHRONOUS ajax call during the validation method to varify uniqueness as follows</p> <pre><code>jQuery.validator.addMethod("new_user_role_name_unique", function(value) { var role_name_valid = true; jQuery.ajax( { type: "GET", async: false, data: "name=" + encodeURIComponent(value), url: '/user_roles/0/name_taken', success: function (result) { var taken = JSON.parse(result); role_name_valid = !taken } }); return role_name_valid; }, I18n.t('user_role_name_already_used')); </code></pre> <p>When I type a name in the "name" text field and then immediately click on the submit button defined below, I would expect the method addUserRole to be called:</p> <pre><code> &lt;button id='user_role_add_button' class='rounded green' type='button' onclick="addUserRole()" name='add' value='add'&gt; &lt;span&gt;&lt;%= t(:user_role_add_button) %&gt;&lt;/span&gt; &lt;/button&gt; </code></pre> <p>However, the method addUserRole is not called. If I type a "name" however and then lose focus on the name text field, prior to clicking the button the method is called with no drama.</p> <p>So in essense, my problem is when the name textfield has focus, I have to double click the save button to ensure addUserRole method is called.</p> <p>Does anyone know why my click event seems to be lost on the first click under these circumstances, but not the second? I cant have the user double click on the button to save.</p>
    singulars
    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