Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Taylor 155 posts 353 karma points
    Nov 25, 2011 @ 11:51
    Mike Taylor
    0

    jQuery code causing conflicts...

    The embedded jQuery code is causing Javascript errors on other datatypes.

    I have a doctype with a Google Maps datatype, and a uComponents Multi-URL Picker. If I try to click on the "Add" link in the Multi-URL picker, the Google Maps JS fails here:

    jQuery(document).ready(function () {

    UmbracoGoogleMap.loadMapsApi('UmbracoGoogleMapMapDataType.guiMap');

    jQuery('input.value').focus(function () {
    $(this).blur();
    });

    $('a').click(function () {
    if ($(this).attr('id').indexOf('TabView') > -1) {
    WebResource.axd:280 Uncaught TypeError: Cannot call method 'indexOf' of undefined
    WebResource.axd:280 Uncaught TypeError: Cannot call method 'indexOf' of undefined (repeated 15 times)

     

    Because the "Add" link doesn't have an ID attribute, I guess...

    Any suggestions?

    Mike

  • Mike Taylor 155 posts 353 karma points
    Nov 25, 2011 @ 13:36
    Mike Taylor
    3

    OK, well, I got it working by downloading the Google Maps source code, and adding a test for the ID attribute around the offending code.

     

    jQuery(document).ready(function () {
    UmbracoGoogleMap.loadMapsApi('UmbracoGoogleMapMapDataType.guiMap');
    jQuery('input.value').focus(function () {
    $(this).blur();
    });
    $('a').click(function () {
    if ($(this).attr('id')) { // <--- Added this to prevent <a> with no id attribute breaking the page
    if ($(this).attr('id').indexOf('TabView') > -1) {
    ...
    }
    }
    });

     

    This works, but it might be better if the Google Maps jQuery limited its scope to the actual instance of the datatype, rather than doing generic selector which intercept every click of every a tag on the page....

    $('a').click(function () { ... });

    Anyway, we're back up and running....

    Cheers,

    Mike

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 27, 2011 @ 20:10
    Tom Fulton
    1

    Thanks Mike, had the same issue and this fixed it.  I went ahead and submitted a pull request to fix it in the source also.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 28, 2011 @ 00:23
    Lee Kelleher
    1

    I've applied Tom's pull request... it will be in the next release (after New Year  - as I'm still away for Christmas).

    Cheers, Lee.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 28, 2011 @ 01:21
    Tom Fulton
    0

    Quit working during your vacation :)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 28, 2011 @ 01:23
    Lee Kelleher
    0

    LOL! Staying with family... they have wi-fi! Still 5 day away from my computer is pretty good for me! ;-)

Please Sign in or register to post replies

Write your reply to:

Draft