Preview Did Not Work – The solution

Home Forums Easy Bootstrap Shortcodes PRO Preview Did Not Work – The solution

Tagged: 

Viewing 0 reply threads
  • Author
    Posts
    • #3435
      Thomas Meyer
      Participant

      I figured out that the preview didn’t work if you are blocking popups in your browser (for me on Safari where no message appears like Firefox do).

      This has to do with your window.open call in ebs_main.js on line 249. The window.open call need to be called from an event initiated by the user, which is not the case here, because it’s called within the ajax call.

      I changed your the code

      jQuery('.ebsp-preview-button').click(function(){
          var $this=jQuery(this);
          $this.parent().find('.spinner').show();
          var shortcode=eval(pluginObj.pluginName+'_generate_shortcode(pluginObj,form,table)');
          jQuery.ajax({
              url:ebs_ajaxurl,
              type:'post',
              data:{
                  action:'ebs_set_preview_content',
                  shortcode:shortcode
              },
              success:function(res){
                  $this.parent().find('.spinner').hide();
                  var  win= window.open(ebs_preview_page_path,'osc_ebs_pro');
                  if (window.focus)
                  {
                      win.focus();
                  }
              }
          });
      })

      to this

      jQuery('.ebsp-preview-button').on('click', function(){
          var preview_path = ''
          var $this=jQuery(this);
          $this.parent().find('.spinner').show();
          var shortcode=eval(pluginObj.pluginName+'_generate_shortcode(pluginObj,form,table)');
          jQuery.ajax({
              url:ebs_ajaxurl,
              type:'post',
              data:{
                  action:'ebs_set_preview_content',
                  shortcode:shortcode
              },
              success:function(res){
                  $this.parent().find('.spinner').hide();
                  preview_path = ebs_preview_page_path;
              }
          });
          var win = window.open(ebs_preview_page_path,'osc_ebs_pro');
          if (window.focus)
          {
              win.focus();
          }
      })

      and it worked still if the browser is set to block popup windows.

      As you can see I saved the ebs_preview_page_path within the ajax call and put the window.open call out of the ajax directly into the .on(‘click’) event. That’s the whole trick.

      Hope this helps to make the plugin work for everyone.

      Cheers
      Thomas

Viewing 0 reply threads
  • You must be logged in to reply to this topic.