Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I prevent a null trigger of an AJAX event?
    primarykey
    data
    text
    <p>With the following jQuery code I have created a drop down that updates the page however I believe that when it changes <code>#content</code> with the returned result it is counting it as a <code>change</code> event and pulling the <code>#sidebar</code> info.</p> <pre><code>&lt;script&gt; var get_pages_load_options = { target: '#content', data: {ajaxtype: 'content'}, beforeSubmit: function() { console.debug('beforeSubmit'); }, success: function() { console.debug('successful'); } }; $("#content").on('change','.get_pages',function(){ var submit_page = $(this).attr('rel'); var form_url = $("#"+submit_page).attr('action'); console.debug(submit_page+" &amp; "+form_url); $("#"+submit_page).ajaxForm(get_pages_load_options); $.ajax({ type: "POST", url: form_url, data: {ajaxtype: "side"}, success: function(data) { console.debug(data); $("#sidebar_menu").html(data); } }); }); &lt;/script&gt; </code></pre> <p>The HTML is as follows for <code>#content</code>:</p> <pre><code>&lt;div id="content" class="content"&gt; &lt;h1&gt;Game Updates&lt;/h1&gt; &lt;form action="/gameplay/updates/" id="submit_page" name="submit_page" class="get_pages" method="post"&gt; &lt;select name="year" class="get_pages" rel="submit_page"&gt; &lt;option value="2012"&gt;2012 -- v1.7.0 - v2.0.0&lt;/option&gt; &lt;option value="2011"&gt;2011 -- v1.5.3 - v1.6.0&lt;/option&gt; &lt;option value="2010"&gt;2010 -- v1.3.3 - v1.5.2&lt;/option&gt; &lt;option value="2009"&gt;2009 -- v1.1.4 - v1.3.2&lt;/option&gt; &lt;option value="2008"&gt;2008 -- v0.6.0 - v1.1.3&lt;/option&gt; &lt;option value="2007"&gt;2007 -- v0.1.x - v0.5.5&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; /** Update Logs **/ &lt;br/&gt;&lt;br/&gt; &lt;p&gt; -----------&lt;br /&gt; Thank you,&lt;br /&gt; Admin deth4uall &lt;/p&gt; &lt;/div&gt; </code></pre> <p>Do you know how I can prevent the second firing of change. Thanks!</p> <p>EDIT: I do have a regular version that is default with the above supposed to be overwriting the below functionality:</p> <pre><code>$("#content").on('change','.get_pages',function(){ var submit_page = $(this).attr('rel'); $("#"+submit_page).submit(); }); </code></pre>
    singulars
    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.
 

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