开发者

Problem will paginate ajax rails?

My problem is this:

I have got a view/action called new. In this action I can create product_packs. Each pack have many products. OK?

Then in new view I have a button which open a popup. This popup allow add_products to pack. This products is paginated with will_paginate plugin. So products pagination code is on action new. OK?

Besides this popup is inside a partial. (The button is a <%= button_to_function "add_product", "BasicModal("id_add_product_partial")"%> which open popup through Simplemodal plugin).

Ok, when I select a product from the list these are loaded in a list. So when i click add products button in popup I don´t want to see this products again. OK?

add_products button go to ajax request ajax where I reload products (I reject selected products).

SO I want paginate products again but the will paginate products render to action new. But must go to add_products ajax action. OK?

I need a solution for rewrite will_paginate links in view.

(Example: when I load action new charge <% will_paginate @products%> but when I selected products and I add to my list replace these will_paginate links with <% will_paginate @products, #links go to add_products action in ajax request %>)

OR

I need load/initialize products wh开发者_JS百科en I open popup. So popup code is not on new view. Popup code load products collection in add_products action so will_paginate links always go to this action.

Thanks in advice and excuse me. If you need the code of my application I post in other answer.


I find a solution for this problem. When I have a little time I am going to publish my code more explanatory.

Broadly speaking, we can combine the ajax pagination described in oficcial gitHub documentation and use Simple modal.

First I create a button_to_remote to remote action and a empty div with a ID attr, then here I could work the logic of my method such that we will use only once the will_paginate plugin with conditions.

Then I could use a RJS or in the controller render :update. There we could use a page.replace_html and fill the empty div with our remote_form (in a partial). then I call Basicmodal function with the ID of empty div.

then I create n the route a map.connect relative_url, :controller "foo", :action :bar.

So we have got a popup with remote pagination in other controller different ,from what is called the current action.

Thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜