做一个远程=>使用javascript进行真正的通话 [英] doing a remote => true call with javascript
问题描述
有没有一种方法可以使link_to ... remote=> true
与使用javascript的行为相同?
Is there a way to have the same behavior as a link_to ... remote=> true
with javascript?
也许没有必要-
我有一个包含用户名和图片的div.
I have a div with the user's name and picture in it.
我希望整个div对单击做出反应,然后转到方法(例如users#show
),就好像它是link_to一样.
I want to have the entire div to react to a click and go to the method (users#show
for example) as if it were a link_to.
link_to的问题是它创建a href
,使文本可链接等.
The problem with link_to is that it creates a href
, making the text linkable etc.
此外,我似乎无法使用它来使整个div只能单击文本.
Also, I can't seem to use it to make the whole div clickable, only the text.
试图更多地解释自己-
如果link_to
对应于javascript中的window.location
If link_to
corresponds to window.location
in javascript
link_to
和:remote=>true
在javascript中是什么?
what is link_to
with :remote=>true
in javascript?
推荐答案
这是您的操作方式:
$.rails.handleRemote($('<a>', { href: '/path', 'data-method': 'GET' }));
这篇关于做一个远程=>使用javascript进行真正的通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!