2015-05-11 61 views
-1

Javascript首先不起作用,但在第二,第三等時間工作。Javascript首先不工作,但在第二,第三等工作時間

;(function ($, window, document, undefined) { 

$variation_form = $('.variations_form'); 

$variation_form.on('show_variation', function(event, variation){ 

    if (variation.variation_description) { 
     $('.variation-description p').html(variation.variation_description); 
    } 
}) 
.on('reset_image', function() { 

    $('.variation-description p').html(''); 
}); 

})(jQuery,window,document);

回答

0

你需要的東西來激發的事件.....

$(".myselector").on('click', function() { 
    $variation_form.trigger('show_variation'); 
}); 

Working Fiddle (again):下面 全部代碼爲P ...

(function($){ 
    $(function(){ 

     $variation_form = $('.variations_form'); 

     $variation_form.on('show_variation', function (event, variation) {     
      if (variation.variation_description) { 
       $('.variation-description p').html(variation.variation_description); 
      } 
     }); 

     $variation_form.on('reset_image', function() { 
      $('.variation-description p').html(''); 
     }); 

     $(".myselector").on('click', function() { 
      $variation_form.trigger('show_variation'); 
     }); 
    }); 
})(jQuery); 
相關問題