Ecshop_jquery compatibility scheme

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 shielding Ecshop the 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 the transport.js renamed to Transport.org.js to provide background use

2, shielding out transport.js Tojson function line number of about 497-737 lines between

by if (! Object.prototype.toJSONString) {begins with code.

Modify the 352 behavior:

Legalparams = “ json=” + $.tojson (params);

Modify the 408 behavior:

result = $.evaljson (result);

Block out the following code (第10-13 line) in Global.js:

Object.prototype.extend = function (object)

{

Return Object.extend.apply (this, [this, Object]);

}

3. Modify the Index.js file 44 to read:

var res = $.evaljson (result);

4. Modify the Common.js file

The 34th line should read:

Ajax.call (‘flow.php?step=add_to_cart’, ‘goods=’ + $.tojson (goods), Addtocartresponse, ‘ post’, ‘ json’);

The No. 850 line should read:

Ajax.call (‘flow.php?step=add_package_to_cart’, ‘package_info=’ + $.tojson (Package_info), Addpackagetocartresponse, ‘ post’, ‘ json’);

The 1056th line should read:

Ajax.call (‘flow.php?step=add_to_cart’, ‘goods=’ + $.tojson (goods), Addtocartresponse, ‘ post’, ‘ json’);

5. Modify the Compare.js file

The 49th line should read:

This.data = $.evaljson (Cookievalue);

The 67th line should read:

var obj = $.evaljson (cookievalue);

The 133th line should read:

Document.setcookie (“compareitems”, $.tojson (This.data));

6. Modify the Global.js file

16th Line Change function name: Functions $e ()

Lines 114th and 126 should read: var element = $e (element);

Second, modify the background call section

7, <!&mdash;&mdash;&mdash;&ndash; Path modification &mdash;&mdash;&mdash;&ndash;>

Modify background header 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.htm

151 line changed to {insert_scripts files= ":/js/global.js,../js/utils.js,../js/transport.org.js"}

third, modify the foreground template section

8, modify the Themes/default/library/page_header.lbi file in {insert_scripts files=&rsquo;transport.js,utils.js&rsquo;} Add the following code above

{insert_scripts files=&rsquo;jquery.js,jquery.json.js&rsquo;}

9. <!&mdash;&ndash; Modify Files &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 DWT file &mdash;-jquery.js file needs to be loaded before Compare.js file loading, otherwise it will error &mdash; &ndash;>

Brand.dwt

Brand_list.dwt

Category.dwt

Exchange_list.dwt

Search.dwt

Such as:

{* Contains script file *}

{insert_scripts files=&rsquo;jquery.js,jquery.json.js&rsquo;}

{insert_scripts files=&rsquo;common.js,global.js,compare.js&rsquo;}

Related Article

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.