【问题标题】:Raty JS not working properly in Vex modalRaty JS 在 Vex 模式下无法正常工作
【发布时间】:2015-09-18 00:04:21
【问题描述】:

我有一个正常工作的 vex 弹出窗口,但是里面的 Raty 评级不能正常工作。他们在网站上的其他任何地方都可以正常工作,但不是在这种模式下。星星出现供您评分(都在同一个功能中),但您不能单击或悬停。

这是我的 Vex 模态的 JS 函数。

$(document).ready ->                                                           
  $("#comment_post").click (event)->
    event.preventDefault();

    vex.defaultOptions.className = 'vex-theme-plain';
    vex.open
      content: $('.rating-modal').html();
      showCloseButton: false
      escapeButtonCloses: false
      closeClassName: "close-rating"

这是 Raty 代码

$(".user_rating").raty({                                                 
  score: 0,                                                              
  half: true,                                                            
  halfShow: true,                                                        
  click: function( score, evt ) {                                        
    $.ajax({                                                             
      type: 'POST',                                                      
      url: "#{store_rating_create_path}",                                
      data: { rating: score, user_id: "#{current_user.id}", store_id: "#{@store.id}" }                                                                     
    }).done(function (data){});                                          
  }                                                                      
});   

没有控制台错误,我不确定发生了什么。星星出现了,但它们不起作用。

【问题讨论】:

    标签: javascript jquery html modal-dialog raty


    【解决方案1】:

    我需要在模态 Click 事件中包含 Raty 代码。呃...所以它最初是在准备好文档时加载的,所以在我触发模态时它已经被触发了,而模态需要再次触发它。所以我把代码移到了模态点击函数里面,一切都很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-13
      • 2020-03-22
      • 2018-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多