best_in_place “:nil” function does not work in AJAX inserted partial

时光总嘲笑我的痴心妄想 提交于 2020-01-14 07:12:32

问题


I have a list of records on my page. I submit a form remotely via AJAX and the new record is appended to the list. All best_in_place features immediately work apart from the :nil option. This doesn't display the default value that I set. This makes it impossible to edit the value unless the user refreshes the page. Then the value is present and the user can click.

Is this a known bug? Can anyone suggest a work around?

Updated with my code:

<%= best_in_place_if can?(:update, post), post, :post_type, :path => account_post_path(account,post), :type => :select, :collection => Post::POST_TYPES.zip(Post::POST_TYPES), html_attrs: { "class" => "span2" }, :nil => "Click to assign" %>

This is inside a partial called _post.html.erb that gets inserted via a create.js.erb file:

$("#js_posts").prepend("<%= escape_javascript render 'post', :post => @post, :account => @account %>");
$("#js_add_post_button").button('toggle');
$("#js_add_post").collapse('hide');
$("#js_add_post").html("<%= escape_javascript render 'add_post', :new_post => Post.new, :account => @account %>");

来源:https://stackoverflow.com/questions/18725948/best-in-place-nil-function-does-not-work-in-ajax-inserted-partial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!