Note that there are some explanatory texts on larger screens.

plurals
  1. POAnchor tag event not firing
    primarykey
    data
    text
    <p>My problem is that my anchor onclick event is not firing. Here is my jquery code</p> <p>This is a pageLoad Event</p> <pre><code>function pageLoad() { </code></pre> <p>I am Binding the context menu Event on an anchor</p> <pre><code>$('#ctl00_ContentPlaceHolder1_gvParamShow a').bind("contextmenu", function(e) { // alert('event fired'); e = jQuery.event.fix(e); $('#contextMenu').parent().css('position', 'absolute'); $('#contextMenu').css('borderColor', 'Black').css('borderStyle', 'Solid').css('borderWidth', '1px').css('backgroundColor', '#EEEEEE').css('color', 'Black'); $('#contextMenu').show(); //alert('appended'); var mouseX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; var mouseY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; document.getElementById('contextMenu').style.top = mouseY + 'px'; document.getElementById('contextMenu').style.left = mouseX + 'px'; return false; }); </code></pre> <p><strong>This is the problem area, Read the explanation at the end of the code</strong></p> <pre><code>$('*').not($('.anchorClass')).mousedown(function() { if ($(this).is('a')) { } else { $('#contextMenu').hide(); } }); } </code></pre> <p>The event to be fired on anchor click</p> <pre><code>function showLiveTrack() { alert('hey'); return false; } </code></pre> <p>Here is my context menu code</p> <pre><code>&lt;div id="contextMenu"&gt; &lt;div&gt;&lt;a onclick="showLiveTrack();" class="anchorClass"&gt;Show Live Track&lt;/a&gt;&lt;/div&gt; &lt;div&gt;&lt;a class="anchorClass"&gt;Bhuwan&lt;/a&gt; &lt;/div&gt; &lt;div&gt;&lt;a class="anchorClass"&gt;Bhuwan&lt;/a&gt; &lt;/div&gt; &lt;div&gt;&lt;a class="anchorClass"&gt;Bhuwan&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Explanation of My Question:</strong></p> <p>I want to fire showLiveTrack() function on context menu anchor click. Also, I want to make the context menu disappear when user clicks anywhere else on the screen. I've tried every possible way that I had in my mind but I am not able to fire the event of this anchor. Instead it makes the context menu disppear. Why? </p> <p>If I remove the below code</p> <pre><code>$('*').not($('.anchorClass')).mousedown(function() { if ($(this).is('a')) { } else { $('#contextMenu').hide(); } }); </code></pre> <p>Then the event gets fired..</p> <p>What Am i doing wrong???</p>
    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