• Resolved nikosillo

    (@nikosillo)


    Hi, I have a problem with the last update of the plugin.
    I have a button integrated in a popup element with a custom javascript code that when pressed, makes a call to a slide external to the popup. The javascript code closes the popup element and opens the slide.
    With the latest version of the plugin this method no longer works, but I can’t find where the modification or the error or the incompatibility could be.
    In the example page, the popup is the one in the “visit” section, icon “i”. Clicking on “show street map” should open the “street map” slide at the bottom of the page.
    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Hardik Sharma

    (@hardiksharma)

    Hi @nikosillo,
    Try this again downgrading to the last working version of the plugin. If your functionality is working. Provide the Code which you have added to run this functionality.

    Thread Starter nikosillo

    (@nikosillo)

    It works perfectly with the previous version, 1.12.1.
    I attach another page with this version where it works correctly.
    The button is from The Plus Elementor, which allows me to insert a shortcode for asign a class and data.postid. The function calls a popup leaflet map.

    // Listen for the event triggered when Travelers' Map is loaded
    document.addEventListener('cttm_map_loaded', function (e) {
    
        //Find all the buttons and add a click event on each
        document.querySelectorAll('.button-link-wrap').forEach((a) => {
          //Get the post id "data-" attribute on the button
          const postID = a.dataset.postid;
          a.addEventListener('click', function (event) {
    		//console.log('link assigned?');
            findAndOpenMarker(postID);
          });
    
          function findAndOpenMarker(postID) {
            // We only have one map, so we will use cttm_markers[0]. If you want to work with multiple maps, you will have to add a second loop.
            for (let i = 0; i < cttm_markers[0].length; i++) {
              // If the marker post ID is the same as the button we clicked AND if it's the main marker.
              if (
                cttm_markers[0][i].additionalData.postid == postID &&
    			cttm_markers[0][i].additionalData.multipleMarkersIndex == 0
              ) {
                
                // If the icon is not on the map, it means it's inside a cluster, 
                // so you have to use .spiderfy() on the parent cluster to open the popup.
                // This will save you a lot of time understanding why it's not working ^^'
                if (!cttm_markers[0][i]._icon) {
                  cttm_markers[0][i].__parent.spiderfy();
                }
                // Open the marker popup
    				//console.log('is modal open or not?');
    			cttm_markers[0][i].openPopup();
    				// Add a nice transition
    			cttm_map[0].panTo(cttm_markers[0][i].getLatLng(), {
                   animate: true,
                   duration: 1,
                });
    	            		
    			
              }
            }
          }
        });
      }, false);

    The “Visit” button “Map” works in the same way, outside the popup.

    This other page shows it working fine with the previous version.

    https://alpujarras-qr.legadoandalusi.es/lanjaron/


    Maybe it’s silly, my knowledge is limited, but it worked. There’s probably something I need to change…
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modal popup and custom javascript’ is closed to new replies.