0

I have a situation where I need to refer a jqplot.pieRenderer.min.js file to a particular script block only. Because if it is used globally at the top, it is throwing error for the other scripts block functions. How can i maintain that js file to particular script block.

I tried below.

 <script src="jquery.jqplot.min.js" type="text/javascript"></script> // global js file
 <script type="text/javascript" src="jqplot.pieRenderer.min.js"> //using specific js
        $(document).ready(function () {
             BindLocationStock();
             BindStatusWiseStock();
        });
 <script type="text/javascript"> //using global js 
        $(document).ready(function () {
             BindBarChart();
        });

Can first script block use global js file and block level js file? I want this scenario. How can I achieve this. Please assist here.

4

2 回答 2

0

据我所知,不可能做你想做的事。

这就是模块模式对 JavaScript 如此有用的原因之一。

我建议重构您的代码以使用模块模式- 这样,您将不会让全局变量相互干扰。

于 2013-10-28T05:02:06.280 回答
0

我认为是冲突问题。您可以jQuery.noConflict像这样使用或包装您的代码:

 <script src="jquery.jqplot.min.js" type="text/javascript"></script> // global js file
 <script type="text/javascript" src="jqplot.pieRenderer.min.js"> //using specific js
  (function ($) {
         BindLocationStock();
         BindStatusWiseStock();
         BindBarChart();
    })(jQuery);
于 2013-10-28T05:04:06.840 回答