Rails html5数据属性未传递

时间:2013-06-26 14:44:51

标签: javascript jquery ruby-on-rails html5

我有一部分显示用户:

%table.table
  %tbody
    - @users.each do |user|
      %tr
        %td= avatar_tag user, {small:true, rounded:true}
        %td
          = username user
          .online-tag
            = user.online?
        %td= email_tag user.email
        %td= user.country
        %td
          - unless user == current_user
            #lll
              = link_to '#messageFormModal', data: {toggle: :modal, receiver: '2'}, class: 'btn btn-primary'  do
                %i.icon--envelope
                = t('globals.send_message')

      = render 'messages/message_form'

我有一个模式,用户点击link_to 'messgeFormModal'后会显示。

我的javascript文件必须捕获传递给模态的属性并提醒他们,但我只看到'undentified'

$(document).on("click", "#lll", function () {
    var receiverId = $(this).data('receiver');
    alert(receiverId);
});

我的语法合适吗?或者我把params传给错了?

1 个答案:

答案 0 :(得分:0)

可能是

$(document).on("click", "#lll a", function () {
    var receiverId = $(this).data('receiver');
    alert(receiverId);
});