Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry but this is not possible at the moment.

    Thread Starter Pierre from DesignBots

    (@mecanographik)

    Hi,
    Thanks for your reply. I try to load the template file ‘event_editor.php’ in a bootstrap modal after i click on a calendar day (wp fullcalendar).
    I know i have to use this function:

    $EM_Event = em_get_event($the_event_id);

    where $the_event_id is a ajax string i call from my ajax function in inline.js
    but i cannot figure it out how to send this string ($the_event_id) to my template file ‘event_editor.php’

    Any idea to achieve this with a function i would pale in functions.php

    Any help would be appreciate, here is my code in functions.php

    add_action('wp_ajax_do_ajax',  __NAMESPACE__ . '\\custom_event_ajax_request');
    add_action( 'wp_ajax_nopriv_do_ajax',  __NAMESPACE__ . '\\custom_event_ajax_request' );
    
    function custom_event_ajax_request() {
    
    // ce switch lancera les fonctions selon la valeur qu'aura notre variable 'fn'
         switch($_REQUEST['fn']){
              case 'em_get_event':
                  $output = $_REQUEST['the_event_id'];
                  //$output = ajax_get_event($_REQUEST['the_event_id']);
              break;
              default:
                  $output = 'No function specified, check your jQuery.ajax() call';
              break;
         }
    
       // Maintenant nous allons transformer notre résultat en JSON et l'afficher
    
         $output=json_encode($output);
         if(is_array($output)){
            print_r($output);
         }
         else{
            echo $output;
            //print_r($output);
         }
         die;
    }

    and here is my jQuery code in wpfullcandar inline.js, one of the arguments in var fullcalendar_args :

    eventClick: function(event) {
    
    			if (event.url) {
    
    			     // We'll pass this variable to the PHP function do_ajax
    				    var the_event_id = event.event_id;
    
    				    /** Ajax Call */
    
    				    // This does the ajax request
    				    $.ajax({
    				       url: WPFC.ajaxurl,
    				        data: {
    				            //'action':'custom_event_ajax_request',
    				           'action':'do_ajax',
    			               'fn':'em_get_event',
    			               'the_event_id' : event.event_id
    				        },
    				        dataType: 'JSON',
    				        type : "POST",
    				        success:function(data) {
    				            // This outputs the result of the ajax request
    				            console.log('success : ' , data);
    				            //$("#insert-event-modal .modal-body").html(data); // just for test
    
    				            $('#insert-event-modal input[name="event_id"]').val(event.event_id);
    							$('#insert-event-modal').modal('show');
    
    				        },
    				        error: function(errorThrown){
    				            console.log('error : ' + errorThrown);
    				        }
    				    });
    				    return false; // no window opening
    	        }
    		},

    i’m able to get a success respond with the correct event_id but how can i transmit it to my modal, which is calling event_editor like that in my themes:
    bp_get_template_part( ‘../plugins/events-manager/forms/event-editor’ );

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘event form shortcode,add some args’ is closed to new replies.