Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've came across the same problem with JSF and PrimeFaces as you. Here is my solution for this problem.</p> <p>You can disable inline functions and restore them as you wish:</p> <pre><code>// get the element with jQuery var element = $('#someId'); // get the current inline onclick function. This works under all browsers. var originalInlineClickHandler = element[0].onclick; // define new click event which will replace the old one. var click = function () { alert('You clicked me!'); } // replace the old "onclick" event with the new one or in other words disable the click element[0].onclick = click; // Now when clicking #someId element the new function will be executed and only it (the "click" function). // Original inline function is gone already and those it will not be executed. // Restore original inline function - a.k.a. enable the click event element[0].onclick = originalInlineClickHandler. </code></pre> <p>This approach works under all browsers. The thing is that all modern browsers change <code>element[0].onclick</code> when you change <code>element.attr('onclick', callback);</code> (meaning that <code>element[0].onclick = eval(element.attr('onclick'))</code> or something similar), but not IE &lt;= IE 7. However if you change <code>element[0].onclick</code> property without even changing the <code>onclick</code> attribute will work under all browsers. In this case <code>onclick</code> attribute doesn't correspond to the real event handler. To keep <code>onclick</code> attribute and property in sync under all browsers the following line could be added:</p> <pre><code>// define new click event which will replace the old one. var click = function () { alert('You clicked me!'); return false; } // update the onclick attribute of the element. Under most browsers this will update and onclick property of the DOM element. element.attr('onclick', click.toString()); // replace the old "onclick" event with the new one or in other words disable the click element[0].onclick = click; </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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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