The perfect solution to the conflict between Ecshop and jquery

Source: Internet
Author: User
Tags setcookie tojson

Ecshop The Ajax event and JSON parsing module in the common/transport.js, it can be said that it also has its own package of tools, which is actually very normal.

But precisely, in encapsulating the JSON various methods while the model of the object is rewritten, this is in conflict with jquery. Because it is well known, jquery expands on a variety of JavaScript objects. All this is easy to understand, each has its own reason is very natural, but the headache and frustration becomes in our users. In the Ecshop forum originally also had a lot of friends raised this question, also proposed a variety of methods, I tried some, bad or even useless, so I had to do it myself. The idea of a solution is probably shieldingEcshopThe extended toJSONString method is replaced with another function. To take care of the side dishes, write down the details. One, modify the default JS file  1, first copy of Transport.js renamed to Transport.org.js to provide backstage use   2, shield off Transport.js function The number of rows is approximately 497-737 lines between the IF (! Object.prototype.toJSONString) {begins with code.   Modify 352 behavior:   legalparams = &ldquo; json=&rdquo; + $.tojson (params);  Modify 408 behavior:  result = $.evaljson (Result);  masks the following code in Global.js (第10-13 line):  Object.prototype.extend = function (object) {  return Object.extend.apply (this, [this, Object]);} 3, modify the Index.js file 44 lines to:  var res = $.evaljson (result),   4, modify the Common.js file 34th line to:  ajax.call (& lsquo;flow.php?step=add_to_cart&rsquo;, &lsquo;goods=&rsquo; + $.tojson (goods), Addtocartresponse, &lsquo; post&rsquo;, &lsquo; json&rsquo;);  No. 850:  ajax.call (&lsquo;flow.php?step=add_package_to_cart&rsquo;, & lsquo;package_info=&rsquo; + $.tojson (package_info), Addpackagetocartresponse, &lsquo; post&rsquo;, &lsquo; json&rsquo;);  1056th line should read:  ajax.call (&lsquo;flow.php?step=add_to_cart&rsquo;, &lsquo;goods=&rsquo; + $.tojson (goods), Addtocartresponse, &lsquo; post&rsquo;, &lsquo; json&rsquo;);  5, modify compare.js the 49th line of the document should read:   this.data = $.evaljson (cookievalue);  67th line to:   var obj = $.evaljson (cookievalue);  133th line instead:   document.setcookie (&ldquo; Compareitems&rdquo, $.tojson (this.data))  6, modify the Global.js file 16th line change function name: Functions $e () 114th and 126 lines are changed to:    var element = $e (Element);   Two, modify the background call section7, <!&mdash;&mdash;&mdash;&ndash; path modification &mdash;&mdash;&mdash;&ndash;> Repair Change the background head to introduce transport.js path admin/templates/pageheader.htm 9th line to: {insert_scripts files=&rdquo;.. /js/transport.org.js,common.js&rdquo;} admin/templates/menu.htm151 Line changed to {insert_scripts files= ". /js/global.js,.. /js/utils.js,.. /js/transport.org.js "} third, modify the foreground template section  8, modify Themes/default/library/page_header.lbi file in {insert_scripts files=&rsquo;transport.js,utils.js &rsquo;} Add the following code {insert_scripts files=&rsquo;jquery.js,jquery.json.js&rsquo;}   9, <!&mdash;&ndash; modify file &mdash;&ndash;>library/comment_list.lbi line 188th:   ajax.call (&lsquo;comment.php&rsquo;, &lsquo;cmt=&rsquo; + $.tojson (CMT), Commentresponse, &lsquo; post&rsquo;, &lsquo; json&rsquo;);   10, COMPARE.DWT line 20th:  var obj = $.evaljson (Document.getcookie (&ldquo; compareitems&rdquo;));  line 24th:  document.setcookie (&ldquo;compareitems&rdquo;, $.toJSON (obj) );   11, flow.dwt line 138th:  ajax.call (&lsquo;flow.php?step=add_to_cart&rsquo;, &lsquo; goods=&rsquo; + $.tojson (goods), Collect_to_flow_response, &lsquo; post&rsquo;, &lsquo; json&rsquo;);  line 199th:   ajax.call (&lsquo;flow.php?step=add_to_cart&rsquo;, &lsquo; Goods=&rsquo; + $.tojson (goods), Fittings_to_flow_response, &lsquo; post&rsquo;, &lsquo; json&rsquo;);   12, <!&mdash;&ndash;jquery files need to be pinned to the DWT file &mdash;- The jquery.js file needs to be loaded before the Compare.js file is loaded, otherwise it will be an error &mdash;&ndash;> brand.dwtbrand_ list.dwtcategory.dwtexchange_list.dwtsearch.dwt  such as: {* Contains script files *}{insert_scripts files=&rsquo;jquery.js, Jquery.json.js&rsquo;} {insert_scripts files=&rsquo;common.js,global.js,compare.js&rsquo;}    one, modify the default JS file   1, first copy of Transport.js renamed to Transport.org.js to provide backstage use   2, shield off Transport.js function The number of rows is approximately 497-737 lines between the IF (! Object.prototype.toJSONString) {begins with code.   Modify 352 behavior:   legalparams = "json=" + $.tojson (params);  Modify 408 behavior:  result = $.evaljson (result);   block out the following code in Global.js (第10-13 line):  object.prototype.extend = function (Object) {  return Object.extend.apply (This, [this, Object]);} 3, modify the Index.js file 44 lines to:  var res = $.evaljson (result),   4, modify the Common.js file 34th line to:  ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + $.tojson (goods), addtocartresponse, ' POST ', ' JSON ');  No. 850 line to:  Ajax.call (' Flow.php?step=add_package_to_cart ', ' package_info= ' + $.tojson (package_info), AddPackageToCartResponse, ' POST ', ' JSON ');  the 1056th line to:  ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + $.tojson (goods), Addtocartresponse, ' POST ', ' JSON '),  5, modify compare.js file 49th line to:   this.data = $.evaljson (Cookievalue);   67th line instead:   var obj= $.evaljson (cookievalue);  133th line should read:   document.setcookie ("Compareitems", $.tojson (This.data));  6, modify the 16th line of the Global.js file, change the function name: Functions $e () 114th and 126 lines are changed to:    var element = $e (Element);   Two, modify the background call section7, modify the background head to introduce transport.js path admin/templates/pageheader.htm 9th line to: {insert_scripts files=. /js/transport.org.js,common.js "} admin/templates/menu.htm151 line changed to {insert_scripts files=" ... /js/global.js,.. /js/utils.js,.. /js/transport.org.js "} third, modify the foreground template section8. Modify the Themes/default/library/page_header.lbi file on {insert_scripts files= ' transport.js,utils.js '} and add the following code {INSERT_ Scripts files= ' Jquery.js,jquery.json.js '} 9, Library/comment_list.lbi line 188th: Ajax.call (' comment.php ', ' cmt= ' + $.  ToJSON (CMT), Commentresponse, ' POST ', ' JSON '); 10. COMPARE.DWT Line 20th: var obj = $.evaljson (Document.getcookie ("Compareitems"));  Line 24th: Document.setcookie ("Compareitems", $.tojson (obj)); 11, flow.dwt 138th Line: Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + $.tojson (goods), Collect_to_flow_response, ' POST ', ' JSON ');  Line 199th: Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + $.tojson (goods), fittings_to_flow_response, ' POST ', ' JSON '); 12, brand.dwtbrand_list.dwtcategory.dwtexchange_list.dwtsearch.dwt such as: {* Contains script file *}{insert_scripts files= ' Jquery.js, Jquery.json.js '}{insert_scripts files= ' common.js,global.js,compare.js '}

The attachment for Ecshop has been modified by the JS file:
Ecshopjs

The perfect solution to the conflict between Ecshop and jquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.