i using ajax crud operation in rails application twitter bootstrap. when click on submit post success flash message showing along close button not showing.
here code ...
<div id="flash_notice" class="alert span6"></div>
here form...
<%= form_for(@post, :remote => true, :html => {:id => "prayer_form"}) |f| %> <div id= "post_errors" style="display:none"></div> <p> <%= f.select :title, options_for_select(["relationship", "family", "health", "personal", "professional", "education", "tours & travel", "exams", "job", "society", "career", "marriage", "relationship", "friendship", "event", "success/failure", "others"]), {:include_blank => "select prayer category"}, {:multiple => false,:class => "required"} %> </p> <p> <%= f.text_area :content, :rows => 5, :class=>"span12 required", :placeholder => "create prayer" %> </p> <p><%= f.submit "add prayer", :class=>"btn btn-primary"%></p> <% end %>
here create.js.erb
$("#post_errors").hide(300); $("#flash_notice").html("<%= escape_javascript(flash[:notice] <button type='button' class='close' data-dismiss='alert'>×</button>) %>"); $("#flash_notice").show(300); $(":input:not(input[type=submit])").val(""); $("#posts_list").html("<%= escape_javascript( render(:partial => "posts") ) %>");
application.js
//= require jquery //= require jquery_ujs //= require bootstrap //= require_tree .
flash alert showing why close icon button not showing. please help
you don't need mix escape_javascript real html code. html code doesn't need go through rails.
try replace this
$("#flash_notice").html("<%= escape_javascript(flash[:notice] <button type='button' class='close' data-dismiss='alert'>×</button>) %>")
with this
$("#flash_notice").html("<%= escape_javascript(flash[:notice] %>" + "<button type='button' class='close' data-dismiss='alert'>×</button>")
Comments
Post a Comment