Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

jQuery not working on view.phtml file when product is viewed in a category
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

I am having one hell of a time with getting Magento to play nicely with jQuery.

I am using a sliding/fading, tabbed navigation to display my description, additional information and other misc information on my product view page (view.phtml)

Got the script to work (with jQuery.noConflict() mode) and am able to see this work when viewing a product when viewed on the root document. E.G. http://www.mydomain.com/my-product.html

But when viewing this product through a category (E.G. http://www.mydomain.com/my-category/my-product.html) the script won’t run!

Does anybody have any clue as to what is going on?? I’m am amateur jQuery/JavaScript guy so my knowledge for deep trouble shooting like this is beyond me so if you can take a look at the two links to my site below that would be great and let me know what is causing this and how to fix please!

Thanks!

Page that works.
http://www.gateequipment.com/ramset-300-ul-1-2-hp-swing-operator.html

Page that doesn’t
http://www.gateequipment.com/gate-operators/swing-arm-operators/ramset-300-ul-1-2-hp-swing-operator.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
hydra
Guru
 
Avatar
Total Posts:  378
Joined:  2008-08-26
Amsterdam
 

Hi,
If you use Firefox you can, after downloading and installing, use the firebug add on. Or if you use IE you can use the developer tools. (just google for them)
These addons can help you a lot to debug these kind of problems.
I didn’t realy have the time to thoroughly check it but is seems that the page of your second link cannot find the feat-prod-slider.js file. It gives a status 404.
Please see attached pictures for more info.
Also have you seen the community module for jquery?
http://www.magentocommerce.com/module/1619/mxperts--jquery-base
.

Image Attachments
firebug2.jpgfirebug1.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

Yes I extensively use Firebug, my best-friend :D

But unfortunately the file you found is not the correct JavaScript file. This is a piece of script that is only used on the home page for a product slider. What I’m looking at is 2 files called “jquery.history_remote.pack.js” and “jquery.tabs.pack.js”

Right now they are being pulled from the JS folder in the SKIN directory. Even though the path is correct when viewing the source the script still won’t run! :(
If you or anybody can please take the time to over look this and see if they can find anything that is causing this script not to run please let me know! Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

Ah ha! I have figured out my problem!

Ok, as I was looking at my head.phtml file is started to recall something I read about how JavaScript is executed. Basically it runs in a cascade like execution. So if you call one script before the other, that’s how it will execute. Looking at my Web Developer Toolbar it was giving me some JS errors. One of them was to a slider that I have on the home page. So when the script is ran it looks for a div called “#slider”, which didn’t exist anywhere but on the home page. So after it couldn’t find that, it would stop reading the rest of my JS.

Since this was the first script being called it would stop reading my script for my tabs and my test replacement script. And after moving this to the bottom, everything started working as expected.

Now my last question is, how do I add a script only to the homepage? I’ll do some more research but figured I’d ask.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hydra
Guru
 
Avatar
Total Posts:  378
Joined:  2008-08-26
Amsterdam
 

Hi,

Good thinking!
.

 
Magento Community Magento Community
Magento Community
Magento Community
 
neochap
Member
 
Total Posts:  40
Joined:  2009-07-09
 

Thanks !!

I was stuck in using an Accordion with jQuery and it wasn’t working for 2 days

Everything seemed to look fine.. in the output html

I saw in Internet Explorer status bar that there was some error.

So I changed the sequence of javascript as suggested in this post and it worked like magic..

Thanks…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top