开发者

JQuery including file with 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜