Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You say you've ran the code on the firebug console and it works fine, which leave very little options here. I believe that the HTML tags you are trying to add those events to haven't been created yet. This will happen if those elements are created via JavaScript and the code which creates them hasn't run yet. Another possibility is that the elements are on the DOM but haven't received those classes yet, also might happen if the classes are given using JavaScript.</p> <p>Give this code sample a try, see if it helps (let me know the results):</p> <pre><code>$(document).ready(function(){ alert('Script loaded.'); $(document) .on('click', '.interaction_type_60', function() { alert("You clicked a case!"); }) .on('click', '.interaction_type_40', function() { alert("You clicked a case!"); }); }); </code></pre> <p><strong>Notice</strong>: The elements you are trying to attach those events to <strong>MUST</strong> be present on the DOM when your original code run and they must have the classes you defined. What my code does is attached the event to the document element and looks for a click event bubbling up the chain of elements, allowing you to add new elements containing those selector and the listeners will be called without you needing to attach the event handler specifically to those elements.</p> <p>P.S.</p> <p>In this specific case you don't even need the <code>$(document).ready(..)</code> part. You can just use:</p> <pre><code>$(document) .on('click', '.interaction_type_60', function() { alert("You clicked a case!"); }) .on('click', '.interaction_type_40', function() { alert("You clicked a case!"); }); </code></pre> <p>Because the events are attached to the document element which is always present.</p> <p><strong>Edit:</strong> After seeing you markup I believe the problem may also be that the inline <code>onclick</code> events use <code>return false;</code> which might be preventing the events from bubbling further up the chain.</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