• Resolved eliasonw

    (@eliasonw)


    Hello Sir,

    I have been trying to figure out why the javascript code I am using is not working in your plugin but is working in table press, below is what is in my header.php theme doc.

    session_start();
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    
    <link rel="profile" href="http://gmpg.org/xfn/11">
    
    <?php wp_head(); ?>
    	<?php //echo $_SESSION['product_title'];?>
    <?php //wp_footer(); ?>
    <script type="text/javascript">
    //(function() {
    jQuery( document ).ready(function() {
    
        
    /*jQuery( ".apply_button" ).click(function() {
      alert(jQuery(this).closest('tr td span.product_title').text());
    });*/
    
    //jQuery("input[name='product-name']").val( "Test" );
    //jQuery('[name="product-name"]').val('new test');
    
    //alert('<?php echo $_SESSION['product_title'];?>');
    jQuery("#product_name").val('<?php echo $_SESSION['product_title'];?>');
    
    jQuery( ".apply_business" ).click(function() {  
     var product_title = jQuery(this).closest('tr').find('.product_title').text();
        var src = product_title;
      //  alert(src);
        //var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
    
        // Send Ajax request to backend.php, with src set as "img" in the POST data
       // jQuery.post("<?php echo home_url(); ?>/tempajax.php", {"product_title": src});
    var ajaxurl = '<?php echo home_url('tempajax.php'); ?>';
    jQuery.post(ajaxurl, { action: 'product_new_title', product_title: src }, function(output) {
    //     alert(output);
      	 window.location.href = 'http://blactec.co.za/business-connectivity-form/';
     });
    
    });
     
    
    //jQuery( ".apply_button" ).click(function() {  
    jQuery(document).on('click', '.small-only a.apply_button', function() {
    	
     	var product_title = jQuery(this).closest('tr').prev().prev().prev().prev().prev().prev().prev().find('.product_title').text();
        var src = product_title;
        //var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
        // jQuery.post("<?php echo home_url(); ?>/tempajax.php", {"product_title": src});
    
    	var ajaxurl = '<?php echo home_url('tempajax.php'); ?>';
    	jQuery.post(ajaxurl, { action: 'product_new_title', product_title: src }, function(output) {
    	     //alert(output);
    	  	 window.location.href = 'http://blactec.co.za/form/';
    	});
    });
    
    jQuery(document).on('click', '.large-only a.apply_button', function() {
    	
     	var product_title = jQuery(this).closest('tr').find('.product_title').text();
        var src = product_title;
        //var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
        // jQuery.post("<?php echo home_url(); ?>/tempajax.php", {"product_title": src});
    
    	var ajaxurl = '<?php echo home_url('tempajax.php'); ?>';
    	jQuery.post(ajaxurl, { action: 'product_new_title', product_title: src }, function(output) {
    	     //alert(output);
    	  	 window.location.href = 'http://blactec.co.za/form/';
    	});
    });
    
    jQuery( ".apply_button_single" ).click(function() {  
     var product_title = jQuery(this).closest('table').find('.product_title_single').text();
        var src = product_title;
      //  alert(src);
        //var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
    
        // Send Ajax request to backend.php, with src set as "img" in the POST data
       // jQuery.post("<?php echo home_url(); ?>/tempajax.php", {"product_title": src});
    var ajaxurl = '<?php echo home_url('tempajax.php'); ?>';
    jQuery.post(ajaxurl, { action: 'product_new_title', product_title: src }, function(output) {
    //     alert(output);
      	 window.location.href = 'http://blactec.co.za/form/';
     });
    
    });
    
    });
    </script>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-114103868-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
    
      gtag('config', 'UA-114103868-1');
    </script>
    
    </head>
    	<?php
    
    		global $dazimaxx_opt;
    
    		$dazimaxx_layout_width = $dazimaxx_opt['dazimaxx_layout_width'];
    		
    		if ( isset( $dazimaxx_layout_width ) ) {
    			$dazimaxx_layout_width_value = $dazimaxx_layout_width;
    		} else {
    			$dazimaxx_layout_width_value = $dazimaxx_layout_width;
    		};
    
    	?>
    <body <?php body_class(); ?>>
    
    	<div id="page" class="site site-wrapper <?php echo esc_attr( $dazimaxx_layout_width_value ); ?>">
    	<div id="dazimaxx">
    		<header class="header-main">
    			
    			<?php
    
    				$dazimaxx_topbar_style = $dazimaxx_opt['dazimaxx_header_top_width'];
    				$page_topbar_switcher = get_post_meta(get_the_ID(),'_dazimaxx_page_topbar_style', true);
    
    				$page_topbar_style = '';
    
    				if($page_topbar_switcher != 'none'){
    					$page_topbar_style = $page_topbar_switcher;
    				} else {
    					$page_topbar_style = $dazimaxx_topbar_style;
    				}
    
    				if($page_topbar_style == 1){
    					get_template_part('/inc/header/header-top-bar-fullwidth');
    				} else {
    					get_template_part('/inc/header/header-top-bar');
    				}
    
                    $dazimaxx_header_style = $dazimaxx_opt['dazimaxx_header_layout'];
    				$single_header_switcher = get_post_meta(get_the_ID(),'_dazimaxx_page_menu_style', true);
                    $page_header_style = '';
                
                
                    if($dazimaxx_header_style){
    					$page_header_style = $dazimaxx_header_style;
    				}
    
    				if($single_header_switcher != 'none'){
    					$page_header_style = $single_header_switcher;
    				}
                
                        if($page_header_style == 'header_full_width'){
    						get_template_part( 'inc/header/header-full-width');
    					}elseif($page_header_style == 'header_style_2'){
    						get_template_part( 'inc/header/header-2');
    					}elseif($page_header_style == 'header_one_page'){
    						get_template_part( 'inc/header/header-one-page');
    					}else{
    						get_template_part( 'inc/header/header-1');
    					}
                
                
    			?>
    			
    		</header>
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    	<div id="content" class="site-content">

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter eliasonw

    (@eliasonw)

    Please help

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    What specific part of your code is not working, and how is it related to the TablePress table?

    Regards,
    Tobias

    Thread Starter eliasonw

    (@eliasonw)

    Hello, thank you so much for your prompt response.

    I have an Apply link that needs to take me to an application form I have http://www.blactec.co.za/form and input the package name into the product field on the form

    If you go to the page above (https://blactec.co.za/connectivity/home/fibre/) and click on the table maker table apply button (any of the options) which is below the table press table the link will take you to the form page and input the package name into the product field.

    I need to use your plugin because it is amazing and table maker does not do what I need.

    Thanks

    Regards
    Warren

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for the explanation.

    It should be sufficient to change

    jQuery(document).on('click', '.small-only a.apply_button', function() {
    

    to

    jQuery('.tablepress').on('click', 'a.apply_button', function() {
    

    here.
    You can then also clean up the code and remove all the duplicate parts.

    Regards,
    Tobias

    Thread Starter eliasonw

    (@eliasonw)

    OMG you are a Genius thank you so much!!!!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Javascript working in Table maker but not tablepress’ is closed to new replies.