Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling JQuery event as function from elsewhere in code...?
    text
    copied!<p>Okay, pretty straight forward JQuery question that I am struggling to find an answer for:</p> <p>I have a JQuery event that is called on button click:</p> <pre><code>$(document).ready(function(){ resetForms('reservation'); $('#form-reservation').submit(function(event){ event.preventDefault(); //the page will no longer refresh on form submit. var resCheck = $(this).find('input[class="reservationid"]').val(); //now we have the reservation ID, let's perform our check. document.cancel_res.cancel_agree.checked = false; //document.cancel_res.cancel_agree.disabled = false; document.cancel_res.cancel_button.disabled=true; document.form_reservation.search_button.value="Searching..."; document.form_reservation.search_button.disabled=true; $.ajax({ url: 'inc/searchres.php', type: 'POST', data: 'resid='+resCheck, success: function(data){ //data is all the info being returned from the php file resetForms('reservation'); //clear forms document.form_reservation.search_button.value="Search Reservation"; document.form_reservation.search_button.disabled=false; $('#reservation-id').val(resCheck); //add read ID back into text box var jsonData = $.parseJSON(data); //BLAH BLAH BLAH BLAH } }); }); }); </code></pre> <p>The function works perfectly... however, is there anyway to call this function without utilizing the submit event? I tried to take out everything after the <code>$('#form-reservation').submit(function(event){</code> call and place it in a separate function, and then call the function from the submit event. However, for whatever reason, this failed.</p> <p>Basically, I want the submit event to still trigger this function, but I also want to be able to call the entire function under other circumstances. Thanks in advance!</p>
 

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