JS not working without prototype
We h开发者_JS百科ave this piece of code:
<a class="loadbutton" onClick="$('checkout_form').submit(); $(this).update('<img src=\'images/loader/longLoad.gif\' /> Processing'); return false;">Pay now<br /><span class="vsmall">click once</span></a>
Which seems to not work if I take out the prototype.js library:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6/prototype.js">
But when I use this library, it conflicts with some other code we are using.. so we want to do it without this prototype library, but still have the same effect on the button.
How can I go about doing this?
Am I right in assuming you're using jquery instead of prototype? If so, then here is how it may look:
<a class="loadbutton" onClick="$('#checkout_form').submit(); $(this).html('<img src=\'images/loader/longLoad.gif\' /> Processing'); return false;">Pay now<br /><span class="vsmall">click once</span></a>
As Ernest mentioned, jQuery.noConflict() may be your best option if you'd like to use both libraries. To do so, you must apply the $.noConflict() before including prototype.
That "$" function is being provided by the prototype library, so that's why it doesn't work when prototype is removed. Is jQuery the other library? jQuery provides a mechanism so that it won't interfere with other libraries that want to use "$".
精彩评论