Note that there are some explanatory texts on larger screens.

plurals
  1. PODon't refresh when typing jquery and coldfusion
    primarykey
    data
    text
    <p>I have a simple page:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script&gt; $(function () { $('#myform').on('submit', function (e) { $.ajax({ type: 'post', url: 'test2.cfm', data: $('form').serialize(), success: function () { //alert('form was submitted'); $("#alldetails").load('details.cfm?randval='+ Math.random()); document.myform.tekst.value = ""; } }); e.preventDefault(); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="myform" name="myform"&gt; &lt;input type="text" name="text"&gt;&lt;br&gt; &lt;input name="submit" type="submit" value="Submit"&gt; &lt;/form&gt; &lt;br&gt; &lt;div id="alldetails"&gt;Loading&lt;/div&gt; &lt;!--- stop when typing comment check and auto refresh ---&gt; &lt;script&gt; var isTyping = false; $("#input-box").focus(function() { isTyping = true; }); $("#input-box").blur(function() { isTyping = false; }); $(document).ready(function() { $("#alldetails").load("details.cfm"); $(document).ready(function() { var refreshId = setInterval(function() { if (!isTyping) { $("#alldetails").load('details.cfm?randval='+ Math.random()); }}, 20000); }); $.ajaxSetup({ cache: false }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>the details are loaded in the div (allDetails) and that is working fine so far. Now on my details.cfm page I'm showing the messages and people can react on them. So far so good, but what I want to do is stop the autorefresh when some is typing a comment. I have try this, see the comment in the code above 'stop when typing and auto rerfesh'. Because the comment input field is on the comment.cfm page, it is ignoring this script.</p> <p>Hope you understand the question.</p> <p>Regards! </p> <p>Edit:</p> <p>the code of details.cfm:</p> <pre><code> &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script&gt; $(function () { $('#testform').on('submit', function (e) { $.ajax({ type: 'post', url: 'save_comment.cfm', data: $('form').serialize(), success: function () { alert('form was submitted'); } }); e.preventDefault(); }); }); &lt;/script&gt; &lt;cfquery datasource="#ns#" name="getdata"&gt; select text, timeline_id from timeline order by t_datum desc &lt;/cfquery&gt; &lt;cfoutput query="getdata"&gt; &lt;p&gt;#tekst#&lt;/p&gt; &lt;cfform id="testform"&gt; &lt;cfinput type="hidden" value="#timeline_id#" name="timeline_id"&gt; &lt;cfinput type="text" name="comment#timeline_id#" id="input-box"&gt;&lt;input type="submit"&gt; &lt;/cfform&gt; &lt;/cfoutput&gt; </code></pre>
    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.
 

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