- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个链接,点击后会重定向到聊天页面。现在,我想从 coffeescript 代码中重定向到该页面。如何模拟下面的链接(带参数)和点击效果一样?
<%= link_to "Send", "#", class: "chat",
"data-sender" => current_user.id, "data-receiver" => user.id
%>
最佳答案
我认为您首先应该在评论部分使用与 Action 电缆相关的更新来更新问题。
像这样的事情应该可行。
received: (data) ->
sender_id = data.sender
reciever_id = data.receiver
link = $('a.chat')
link.attr('data-sender', sender_id) # To set data attributes for the link
link.attr('data-receiver', receiver_id)
link.trigger('click') # Triggering a click so that the rest of the code can take over
我不知道您的应用程序如何工作。
我想做的是更新数据属性或链接到从 Action 电缆获得的值,然后触发链接上的点击事件,以便您应用中的其余代码可以接管。
关于javascript - 在coffeescript中模拟链接点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46947176/
menu Home Events Technical Schedule
我试图阻止触发默认 anchor 链接和 onclick 事件。 这是 HTML 代码: Google 我正在尝试使用以下 jQuery 代码阻止任何重定向的发生: $("#mylink").cli
我想在单击父 div 上的任意位置时切换我的 div,除非单击 anchor 元素。因此,例如,如果我单击示例中的第一个文本,我希望它切换,但在我的示例中的第二个文本上,我不希望它切换。 JSFidd
我在通过 jQuery 伪造 anchor 点击时遇到问题:为什么我的thickbox在我第一次点击输入按钮时出现,但第二次或第三次却没有出现? 这是我的代码: Link 当我直接点击链接时,它总是
我已经从 Mootools 切换到 jQuery,因为我认为它有更好的支持。我有这样的 HTML: Opcje Opcje Opcje Opcje Opcje Opcje Opcje JS
我是一名优秀的程序员,十分优秀!