How to use javascript class from within document ready

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-05-23T05:08:52Z Indexed on 2010/05/23 5:10 UTC
Read the original article Hit count: 346

Filed under:
|
|

Hi,

I have this countdown script wrapped as an object located in a separate file

Then when I want to setup a counter, the timeout function in the countdown class can not find the object again that I have setup within the document ready.

I sort of get that everything that is setup in the document ready is convined to that scope, however it is possible to call functions within other document ready´s.

Does anyone has a solution on how I could setup multiple counters slash objects. Or do those basic javascript classes have to become plugins

This is some sample code on how the class begins

function countdown(obj)
{
    this.obj        = obj;
    this.Div        = "clock";
    this.BackColor      = "white";
    this.ForeColor      = "black";
    this.TargetDate     = "12/31/2020 5:00 AM";
    this.DisplayFormat  = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
    this.CountActive    = true;

    this.DisplayStr;

    this.Calcage        = cd_Calcage;
    this.CountBack      = cd_CountBack;
    this.Setup      = cd_Setup;
}

thanks, Richard

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery