Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2012
    Location
    South Carolina
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding any additional JavaScript is breaking functionality within jQuery modal

    I have a page created by someone else that contains modal windows, and each modal window has links/images that display on hover. FYI, I have a very limited understanding of JavaScript and jQuery.

    I want to add Google Analytics tags to the links in the modal windows. Usually, I just add:

    Code:
    onclick="_gaq.push(['_trackEvent','Parameter 1', 'Parameter 2', 'Parameter 3']);"
    directly to the anchor tag, but whenever I add the code to the anchor tag in the HTML, the jQuery stops working. The modal windows work correctly on this link: http://cookware.lecreuset.com/cookwa...10151_-1_20002

    and you can see what I mean by "stops working" on the following link - the items within the list tags are no longer being populated, which means the icons don't show up and the new content that displays on hover can't be accessed: http://cookware.lecreuset.com/cookwa...10151_-1_20002

    Since most of the links are created in the jQuery, I started by trying to add the Google Tag via .click, .attr, .on and .bind with no luck. The link above shows you my attempt with the .click function (search for CIGuide and you'll find it in the source), but it breaks in the same way no matter what JavaScript I add to the page.

    After I wasn't able to get either of those two things to work, I decided to try a simple alert on the page outside of all the content I was provided, with it's own JavaScript tags, just to see if I could get that to work. It worked perfectly, but the modal functionality still broke.

    I have been able to successfully add the Google Tags to the anchor in the top navigation, and to the arrows on the left and right side of the page. But anytime I try to tag anything else, it breaks.

    The agency I'm working with is able to add the google tag to the anchor with no issue when they test it on their server, and I am able to see the event fire if I test it on my local machine. I have to assume there is a problem on my server or with OpenCMS. However, I don't see any error messages in any browser/debugger, and I have validated my script additions with JSLint, and everything checks out.

    This is driving me nuts! Can anyone help me figure out why this won't work and how I can add event tags to the page?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,609
    Thanks
    0
    Thanked 645 Times in 635 Posts
    What does the error console say? It usually identifies what has stopped the script from working.

    If that doesn't help then turn on the debugger in your browser (F12 in IE, chrome, Safari and Opera).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Jun 2012
    Location
    South Carolina
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not seeing any errors, that's the frustrating part. I have checked in FF, Chrome, and I have the script error/debugger on in IE and it doesn't register any errors.

    Last night I also tried changing the _gaq.push call to console.log just to see if that would work, but it still breaks it.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •