Note that there are some explanatory texts on larger screens.

plurals
  1. POprototype and jQuery peaceful co-existence?
    primarykey
    data
    text
    <p>I know very little about JavaScript but despite this I'm trying to cobble something together on my wordpress blog. It's not working, and I don't know how to resolve it, and hey, that's what StackOverflow is for, right?</p> <p>Firstly, the error message is:</p> <pre><code>Error: element.dispatchEvent is not a function Source File: http://.../wp-includes/js/prototype.js?ver=1.6 Line: 3936 </code></pre> <p>It happens on page load. My page load handler is registered thusly:</p> <pre><code>Event.observe(window, 'load', show_dates_as_local_time); </code></pre> <p>The error goes away if I disable some other plugins, and this (plus googling) led me to conclude that it was a conflict between prototype and jQuery (which is used by some of the other plugins).</p> <p>Secondly I'm following the wordpress recommended practice of using <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="nofollow noreferrer"><code>wp_enqeue_script</code></a> to add a dependency from my JavaScript to the Prototype library, as follows:</p> <pre><code>add_action( 'wp_print_scripts', 'depo_theme_add_javascript' ); function depo_theme_add_javascript() { wp_enqueue_script('friendly_dates', 'javascript/friendly_dates.js', array('prototype')); } </code></pre> <p>Now I'm also aware that there are some potential conflicts between jQuery and Prototype which are resolved using the jQuery <code>noConflicts</code> method. I've tried calling that from various places but no good. I don't <em>think</em> this is the problem because a) the <code>noConflict</code> function relates solely to the <code>$</code> variable, which doesn't seem to be the problem here, and b) I would <em>expect</em> wordpress to sort it out for me because it can...</p> <p>Lastly, using the Venkman debugger I've determined that the <code>element</code> referenced in the error message is indeed an <code>HTMLDocument</code> but also does lack a <code>dispatchEvent</code>. Not sure how this could happen, given it's a standard DOM method?</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