• Resolved downfast

    (@downfast)


    is it possible to load the shortcode via jquery click?

    Hi Darren
    is it possible to load the shortcode via a jquery button click?
    If I run this it works but it won't load the content but only the container
    
    	var loc;
    	var $shortCode = '<?php echo do_shortcode("[ajax_load_more post_type='post' search='Hot dog']"); ?>'
    	var $go = '<?php echo $shortCode; ?>'
    	function panelShow(e) {
    		$(".panel_block").show();
    		loc = e.target.feature.properties.name;
    		var sh = '<?php echo $sh ?>';
            	$('.panel_block').html($shortCode);
    	}
    
    Thanks
    • This topic was modified 7 years, 5 months ago by downfast.
    • This topic was modified 7 years, 5 months ago by downfast.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @downfast,
    That’s possible but you would most likely need to enqueue the ALM js manually as the JS is only enqueued when added via shortcode on page load.
    Then call the following function after appending the content to the page.

    if ($(".ajax-load-more-wrap").length){
          $(".ajax-load-more-wrap").ajaxloadmore();
       }
    Thread Starter downfast

    (@downfast)

    I am having this:

    jQuery.fn.almTriggerClick is not a function(…

    When I do

                        if ($(".ajax-load-more-wrap").length){
                            $(".ajax-load-more-wrap").ajaxloadmore();
                            jQuery.fn.almTriggerClick();
                        }
    Thread Starter downfast

    (@downfast)

    This is the full code (NOTE: I need to call it many times, so it isn’t just one shot)

            if(btnClick == true) {
                btnClick = false;
                var $shortCode = '<?php echo do_shortcode("[ajax_load_more post_type='post' pause='true' meta_key='country:year' meta_value='LOCATION:TIME' meta_compare='IN:IN' meta_type='CHAR:CHAR' meta_relation='AND' button_label='SPIMEING']"); ?>'
    
                $('.panel_block').html($shortCode);
    
                this.getElement().classList.add('active');
                jQuery(".panel_block").show(function(){
                    jQuery(".ajax-load-more-wrap ul").attr("data-meta-value", loc + ":" + date);
                    jQuery.fn.almTriggerClick();
                });
    
                setTimeout(
                    function() {
                        if ($(".ajax-load-more-wrap").length){
                            $(".ajax-load-more-wrap").ajaxloadmore();
                            
                        }
                }, 500);
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Load shortcode via jquery button click’ is closed to new replies.