开发者

JQuery including file with constants

开发者 https://www.devze.com 2023-02-15 00:54 出处:网络
I have the following jQuery constants file which looks something like this: function($) { var Constants ={

I have the following jQuery constants file which looks something like this:

function($) { 
    var Constants =     {
        DECIMAL_SEPARATOR: ",", 
    ....
    } })(jQuery);

I'm referencing to the file in the <head> section of the HTML page.开发者_如何学Python Later down I'm using those variables in jQuery script calls, like this:

$("$.financeTable input").numeric(Constants.DECIMAL_SEPARATOR);

When including the file in the <head> element it doesn't work, but when I copy the same code into the <script> tag in the same file it works.

How can that be?


Ok I found it, it must be:

(function($) {

$.Constants = 
{
    DECIMAL_SEPARATOR: ",", 
    ...
    } })(jQuery);

and used like this:

alert($.Constants.DECIMAL_SEPARATOR);


Could it be that you are including the file before jQuery?

0

精彩评论

暂无评论...
验证码 换一张
取 消