I’m trying to use a jQuery function to put a partial into my code. The jQuery is pretty simple, but how can I input Rails code so I don’t have to write the html from scratch?
Here’s what I have so far:
function addCommentBoxToID(myID)
{
$('#post' + myID + ' .postcontent tbody').append('I want to put rails code here');
}
Thank you!
That would not be the way to do it. You cannot include a partial in your code true jQuery.
jQuery is clientside, Ruby on Rails code is executed on the server. You cannot execute Rails code true jQuery.
Closest to what you want including html content generated by rails would be using some ajax to call you rails app and give a command to spit out a piece of HTML. Look into rails and ajax on railscasts.com to get a basic idea.