getThemePath within script

Permalink
I have created a vertical menu using css and jquery which works fine outside Concrete5 - designed and written using Dreamweaver.

I have converted the site I am working on to a Concrete5 theme and can get everything working except for certain images which need to be placed using jquery.

The following bit of jquery works but only on the Home page!

$(this).parent("ul.nav li").css({'background-image':'url(themes/butterflies/images/button_ov.gif)'});

If I could use getThemePath within the jQuery it would be easy!
The pathname changes when I move to other pages:

Home Page:
http://localhost/conc/themes/butterflies/images/button_ov.gif...

About us Page:
http://localhost/conc/index.php/about-us/themes/butterflies/images/...

As you can see , I am running this locally using XAMPP.
Any ideas how I can get around this please?????

Thanks
Vern

vernb
 
jordanlev replied on at Permalink Reply
jordanlev
You need to "inject" the path into your javascript using php, like this:
$(this).parent("ul.nav li").css({'background-image':'url(<?php echo $this->getThemePath(); ?>/images/button_ov.gif)'});


(Note that this only works if that line of javascript code is actually in your theme template file -- if it's somewhere else let me know and I can give you slightly different code that should work).

-Jordan
vernb replied on at Permalink Reply
vernb
Thanks Jordan... I had already tried that but still the button would not show.

However, I decided to use addClass/removeClass instead with the button url in the css. The class was definitely being added and removed but still no button appeared... the solution was in the css!!!

All sorted now and THANKS again.
Vern