Rails 3 link_to and JQuery
I'm trying to use Rails to show links (featuring :remote => true
) on a page, "currentPage" using jQuery.append()
.
What I want to do: I am using Juggernaut (a push server) to push data from "currentPage" to update a counter of another page, using the following code (which doesn't work). Am I on the right track? If there is an easier/b开发者_JS百科etter-form way to do this, please let me know.
var push_question_link = "<%= escape_javascript(link_to('Link', 'results')) %><br />";
$('#myDiv').append(push_question_link)
I want the 'Link' string to be a JavaScript variable, but once I use escape_javascript
I can't call the variable.
Thanks, Derek
Try setting the href property of that link with your variable after you have done a .append(push_question_link)
Even though the rails link_to statement will generate the link with a static url, manually overriding it next might do the trick. Good luck!
精彩评论