google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Xử lý xung đột giữa Prototype và jQuery Bài viết này sẽ hướng dẫn bạn cách xử lý tranh chấp giữa jQuery và Prototype để có thể sử dụng đồng thời hai thư viện JavaScript này trên cùng một trang web.


Nhãn: xử lý, xung đột, Prototype, jQuery, tranh chấp, thư viện JavaScript

Miễn phí web hosting 1 năm đầu tại iPage



Nếu bạn vẫn còn đang tìm kiếm một nhà cung cấp hosting đáng tin cậy, tại sao không dành chút thời gian để thử với iPage, chỉ với không quá 40.000 VNĐ/tháng, nhưng bạn sẽ được khuyến mãi kèm với quà tặng trị giá trên 10.000.0000 VNĐ nếu thanh toán cho 24 tháng ~ 900.000 VNĐ?

Có trên 1 triệu khách hàng hiện tại của iPage đã & đang hài lòng với dịch vụ, tuyệt đối chắc chắn bạn cũng sẽ hài lòng giống họ! Quan trọng hơn, khi đăng ký sử dụng web hosting tại iPage thông qua sự giới thiệu của chúng tôi, bạn sẽ được hoàn trả lại toàn bộ số tiền bạn đã sử dụng để mua web hosting tại iPage. Wow, thật tuyệt vời! Bạn không phải tốn bất kì chi phí nào mà vẫn có thể sử dụng miễn phí web hosting chất lượng cao tại iPage trong 12 tháng đầu tiên. Chỉ cần nói chúng tôi biết tài khoản của bạn sau khi đăng ký.

Nếu muốn tìm hiểu thêm về ưu / nhược điểm của iPage, bạn hãy đọc đánh giá của ChọnHostViệt.com nhé!
Thử iPage miễn phí cho năm đầu tiên NGAY

I experienced this conflict quite recently when I was working on WordPress Featured Articles Plugin. Normally jQuery.noConflict() comes to the rescue but not in my case. And the reason being - prototype was already interacting and was included at the top, so it was already using the $ variable.

This conflict causes the creation of the jQuery object to fail.

 

All the following errors are related to this conflict and you might get one or all of the following while using Prototype (Scriptaculous) and jQuery -

jQuery is not defined

$ is not a function

$ is not defined $(document).ready(function(){

Component returned failure code: 0×80040111 JavaScript error

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMViewCSS.getComputedStyle]" nsresult: "0×80004005 (NS_ERROR_FAILURE)"

What can we do to fix this?

You can try moving the jQuery.js to top and than use jQuery.noConflict().

If that is not an option you can do the following -

IMPORTANT - Do not use [REPLACE ALL]

  • Edit prototype.js - find where it defines function $() and change the name to function $$$()
  • Still in prototype.js, carefully replace each occurrence of $(... ) with $$$(... ), but don't touch anything which says $$(... )
  • Edit each of the other *.js files (e.g. effects.js) and carefully replace each occurrence of $(... ) with $$$(... ), but don't touch anything which says $$(... ).
  • That is it.

And just in case you have trouble doing the above, Following links point to already edited prototype.js and effects.js. Please remember all the references to these files must start with $$$ instead of $.

Download - Prototype.js

Download - Effects.js

Hopefully this article will help some of our fellow coders and save them some time and frustration. Happy Coding guys :)

iPhoneKer.com
Save up to 630$ when buy new iPhone 15

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

https://tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
Talk to ChatGPT by your mother language

Dall-E-OpenAI.com
Generate creative images automatically with AI

AIVideo-App.com
Render creative video automatically with AI

JavaScript theo ngày


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web