Created
December 24, 2013 18:02
-
-
Save guinslym/8116345 to your computer and use it in GitHub Desktop.
Wrong javascript output. I'm trying to load a form using Javascript. So that when I user click on "new Comment" it will append the 'comment form' but when I clicked on the link it renders $("<form accept-charset=\"UTF-8\" action=\"/articles/3/comments\"...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("<%= escape_javascript render(:file => 'comments/new.html.erb') %>").insertAfter('#comments'); | |
$('#new_comment_link').hide(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("<form accept-charset=\"UTF-8\" action=\"/articles/3/comments\" class=\"new_comment\" id=\"new_comment\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"zSq3KpEbucFQLa6XStEJ/I0+CpKPLFYcU/WGIdneeMg=\" /><\/div>\n<div class=\"field\">\n<label for=\"comment_name\">Name<\/label><br />\n<input id=\"comment_name\" name=\"comment[name]\" type=\"text\" />\n<\/div>\n<div class=\"field\">\n<label for=\"comment_email\">Email<\/label><br />\n<input id=\"comment_email\" name=\"comment[email]\" type=\"text\" />\n<\/div>\n<div class=\"field\">\n<label for=\"comment_body\">Body<\/label><br />\n<textarea id=\"comment_body\" name=\"comment[body]\">\n<\/textarea>\n<\/div>\n<div class=\"actions\">\n<input name=\"commit\" type=\"submit\" value=\"Add\" />\n<\/div>\n<\/form>").insertAfter('#comments'); | |
$('#new_comment_link').hide(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render @article %> | |
<h3>Comments</h3> | |
<div id="comments"> | |
<%= render @article.comments %> | |
</div> | |
<%= link_to "new comment", new_article_comment_path(@article, :format => :js), :remote => true, :id => 'new_comment_link' %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment