0

我有一部分要显示用户:

%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);
});

我的语法对吗?或者我可能错误地将参数传递给它?

4

1 回答 1

0

大概是

$(document).on("click", "#lll a", function () {
    var receiverId = $(this).data('receiver');
    alert(receiverId);
});
于 2013-06-26T14:48:52.303 回答