Support » Plugin: Events Manager » How can I manipulate the content within the maps info window with javascript

  • Resolved lucaz5520

    (@lucaz5520)


    I just want to start off by saying that this did not work.

    jQuery(document).bind('em_maps_location_hook', function( e, map, infowindow, marker ){
    2
        ....
    3
    });

    Ok the way I am using map is with the short code [locations_map]

    Now within the maps info window I have formatted it to display #_LOCATIONNEXTEVENTS so that I can see all of the upcoming event dates for that specific location. It all work out fine except the fact that I do NOT want it to display the time.

    What the formatting looks like: – May 19 – May 20 – 12:00 am

    I am trying to get rid of – 12:00 am with javascript which is easy with the replace function but I cannot seem to target the content within the info window at all.

    There is couple of li’s nested within a ul within the infowindow and I am tring to target all of the li’s and their text like so.

    $('#inner-map-info li').each(function(index, el) {
    	$(el).text().replace('- 12:00 am','');
    });

    but like I mentioned I cannot seem to target any elements within the infowindow of the map event, not even with the bind function. Does anyone know what’s going on?

    And just for the sake of testing I wrote all of this code within my footer.php within a script tag at the bottom, which shouldn’t be a problem but I just thought that was worth mentioning.

    https://wordpress.org/plugins/events-manager/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support caimin_nwl

    (@caimin_nwl)

    NetWebLogic Support

    Is your code being run after the page loads?

    Yes it is, and just to make sure that this was not a dependency issue I used the setTimeOut method with the delay of 3 seconds and still no go.

    I know for a fact that it’s not the code that I wrote because even if you try to do something simple like making all of the li’s within the info window the color of red, nothing will happen.

    Plugin Support caimin_nwl

    (@caimin_nwl)

    NetWebLogic Support

    With respect, since this is custom code – and it’s running at the correct point – then there must be something awry with the code.

    One thing that stands out is that el is used as an argument but $(el) is used later in the code.

    Did you mean to do something like var el = $(this); ?

    Ok forget about my code.

    Just this will not work.

    jQuery(document).bind('em_maps_location_hook', function( e, map, infowindow, marker ){
     alert('Hi');
    });

    No matter where I place it or even if I give a setTimeOut or anything it will NOT work at all.
    I have tried putting it in the header.php, footer.php and in a custom JS file.
    I have come to believe that it is a problem with em_maps_location_hook

    Plugin Support caimin_nwl

    (@caimin_nwl)

    NetWebLogic Support

    Are you containing that code within a document ready or onload statement?

    Yes I have tried that,

    jQuery(document).ready(function($){
         $(document).bind('em_maps_location_hook', function( e, map, infowindow, marker ){
              alert('hi');
         });
    });

    I have also tried onload… I have tried everything I can possibly think of and iv came to the conclusion that the bind method is not firing because it is not binding to em_maps_location_hook for some reason.

    Hey so I found out whats going on. It looks like the hook name in the documentation is wrong… It’s says to bind to em_maps_location_hook when the word location should be plural like this em_maps_locations_hook.

    So when I did this it finally worked:

    jQuery(document).ready(function($){
    	jQuery(document).bind('em_maps_locations_hook', function( e, map, infowindow, marker ){
    		alert('hi');
    	});
    });

    @caimin_nwl Thanks for taking the time, appreciate it!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How can I manipulate the content within the maps info window with javascript’ is closed to new replies.