2

I am trying to add a enter link description here

what I have done :

  1. add below div in 1column.phtml

    <div id="countdown1"></div>
    
  2. added below code in footer script (inside <script> tag) via admin panel.

    $('#countdown1').ClassyCountdown({   theme: "flat-colors",   end: $.now() + 10000  });
    
  3. corresponding supported files are added in page.xml

    js/jquery.knob.js
    js/jquery.throttle.js
    js/jquery.classycountdown.js
    css/jquery.classycountdown.css
    

But I am getting an error -

Cannot read property 'ClassyCountdown' of null

How can I resolve this issue ?

2

I replace

$(document).ready(function(){" 

with

jQuery(document).ready(function($){" 

and now it working.

  • I can't. Must wait some time. Will do it. – Oleg Shushkovsky Feb 3 '15 at 7:46
0

Most probably your custom script for activate count downs (script that you added via admin panel) may be added above those supporting script files. Also you should avoid core code editing if possible. (I can see an edit made at page.xml).

I think all of these things you can do via local.xml. It would be much more cleaner way of doing this type of stuffs. Try this :

File : app/design/frontend/<package>/<theme>/layout/local.xml

<layout>
    <default> <!-- use an appropriate layout update handle -->
        <reference name="head">
            <action method="addItem"><type>skin_js</type><name>js/jquery.knob.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/jquery.throttle.js</name></action>
            <action method="addItem"><type>skin_js</type><name></name>js/jquery.classycountdown.js</action>
            <action method="addItem"><type>skin_js</type><name></name>css/jquery.classycountdown.css</action>
            <action method="addItem"><type>skin_js</type><name></name>custom.js</action>
        </reference>
    </default>
</layout>

Now add every js files which are mentioned above at skin/frontend/<package>/<theme>/js/.

As you can see, here I am added one more js file custom.js in which you can add your custom js codes. It will included after every other supporting js files now. Put below content over there.

File : skin/frontend/<package>/<theme>/js/custom.js

$(document).ready(function(){
    $('#countdown1').ClassyCountdown({   theme: "flat-colors",   end: $.now() + 10000  });
});

That's it . Now clear the cache and then try again.

  • still nothing :( same error. if i add "$(document).ready(function(){", error for it sring - "Uncaught TypeError: undefined is not a function". If I delete it error "Uncaught TypeError: Cannot read property 'ClassyCountdown' of null" on string "$('#countdown1').ClassyCountdown({ theme: "flat-colors", end: $.now() + 10000 });" – Oleg Shushkovsky Feb 2 '15 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.