I have tried to include a partial into a modal something similar to this Rails Admin when you click on "create language".
由于我没有真正发现该法典如何运作,我试图在以下网站之间作搭配: and some own.
事实是,部分货物现已进入运输方式。 但是,当我打上“勇敢”时,验证将回复到“正常”的形成新观点,而不直接显示模式内的验证错误。
我怎么能够直接展示出在流行式modal形中的验证错误?
在我节省费用时,我应该对除这种方式外的某种方式与正常的节省加以区分,因为这一部分将与其他部分分开,并且需要将新制造的物体直接设定为一滴新的目标。 我猜想,需要区分反应格式,然后利用联合材料确定DroopDown id的新补贴?
在这方面,迄今为止已经撰写了一些法典。 我认为,在我列入部分内容时,我视之为另一种控制者(正如我对另一个控制者——新观点的看法)。
$.get( <%= url_for :controller => customers , :action => new %> ,
function(data) {
$( #customer-modal ).html(data);
}
);
接着,“底线”控制器中的新内容区分了不同申请格式,使部分不同(在这种情况下,“......ajax_form.html.erb”):
if request.xhr?
render "_ajax_form", :layout => false
在这一部分中,我使用了“简单_form_for @customer, :remote => real do
<div class="modal-footer">
<%= f.button :submit, :class => btn primary %>
<a id= cancel-form class= "btn small info">cancel</a>
</div>
Thanks for any help which clarifies what I am doing wrong or how it should be done as my experience in Rails and JS/AXAX are not yet too experienced.. ;)
- EDITED: I have now a version where in my special partial which is loaded within the modal, will call a seperate action called "new_from_sale" within the simple_form_for:
simple_form_for @customer, :url => url_for(:action => new_from_sale,: Controller =&user ; : ed ; >
Then in the controller, when the save is ok of this new object, I redirect to the first called view with the new id as a param which then fills the dropdown. In the else case, when the new object can not be saved, I need somehow to show the errors still in that modal.
So far both tries to either directly render the partial render :partial => "customers/ajax_form"
or give back JS code render :js => "$( #sale_customer_id ).val(#{@customer.id});"
would not yet work.. but I ll keep on trying my luck..