English 中文(简体)
铁路部分在运输方式中(从不同的模式中排出部分)
原标题:Rails partial in modal (render partial from different model)

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.

事实是,部分货物现已进入运输方式。 但是,当我打上“勇敢”时,验证将回复到“正常”的形成新观点,而不直接显示模式内的验证错误。

  1. 我怎么能够直接展示出在流行式modal形中的验证错误?

  2. 在我节省费用时,我应该对除这种方式外的某种方式与正常的节省加以区分,因为这一部分将与其他部分分开,并且需要将新制造的物体直接设定为一滴新的目标。 我猜想,需要区分反应格式,然后利用联合材料确定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..

最佳回答

下面是我针对类似问题(撰写的示范表格的基本例子。 铁路和联dia形式:

https://github.com/ramblex/pl-form

You need to add :remote => true to the form that gets loaded into the dialog. That will cause the JS format to be rendered from the create action. You can then handle the response in a create.js.erb.

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.