ok, so I'm fully clear, this is an index view that you want to be able to switch between viewing latest and viewing all with an ajax update rather than re-rendering the page? Some of the naming was throwing me off assuming that's the case.
Try something like this. <do part='finished_article_table' part-locals="@page"> <table-plus with="&page" fields="page, created_at" > </table-plus> </do> I think what's going on, is it's not using the updated context (which, this still might not get it there) because it's passed as an instance variable. I'm not sure by any means but maybe it will get you going again. On Nov 17, 1:09 pm, Pete <[email protected]> wrote: > ... sorry again (what am I doing.... long day!) > > :update => 'finished_article_table' > > On Nov 17, 8:06 pm, Pete <[email protected]> wrote: > > > yep, sorry! it is a typo should be :update => > > '''inished_article_table' > > > this was correct in my code, just a typo here........ > > > On Nov 17, 7:40 pm, kevinpfromnm <[email protected]> wrote: > > > > Is :update => ''finished_article_table' a typo? mismatched quote > > > types. > > > > On Nov 17, 8:15 am, Pete <[email protected]> wrote: > > > > > Thanks Kevin, > > > > > The part mechanism certainly seems like a good logical step in > > > > updating specific sections of the page, I like it! :) > > > > > I had a look at a lambda in the named scope, but this seemed to > > > > restrict what I was trying to achieve with my particular models and > > > > fields. > > > > > What I have managed to build so far is: > > > > > my controller method ----- > > > > > def finishedArticle > > > > > �...@myoption = params[:stateSelect] > > > > > if @myOption == 'Latest' > > > > > �...@page = > > > > Page.finished_pages.latest_finished.apply_scopes( :search => > > > > [params[:search], :page, :created_at ], :order_by => > > > > parse_sort_param(:page, :created_at )).paginate(:per_page => 25, :page > > > > => params[:page]) > > > > > else > > > > > �...@page = Page.finished_pages.apply_scopes( :search => > > > > [params[:search], :page, :created_at], :order_by => > > > > parse_sort_param(:page, :created_at :)).paginate(:per_page => > > > > 25, :page => params[:page]) > > > > > end > > > > end > > > > > Then in my view for finished Articles, I have: > > > > > <%= select_tag "stateSelect", options_for_select(['All', 'Latest'], > > > > 'All'), { :onchange => remote_function( > > > > :update => 'finishedArticles', > > > > :with => 'Form.Element.serialize(this)', > > > > :url => {:action => > > > > 'finishedArticles'}) } %> > > > > > <table-plus part='finished_article_table' with="&@page fields="page, > > > > created_at" > > > > > </table-plus> > > > > > I feel like I am almost there with what I am trying to achieve, the > > > > webpage loads initially with all of the finished articles showing in > > > > the table, and when I use the select menu, to choose 'Latest, I can > > > > see from the console that the correct data is extracted from the > > > > database - and has picked up the chained named scope - (if @myOption = > > > > 'Latest' .... Page.finished_pages.latest_finished), however, I cannot > > > > get the contents of the table to update. If I change :update => > > > > 'finishedArticles', to :update => ''finished_article_table', I get a > > > > blank page with the text 'Latest' shown in the top corner? > > > > > I have thought about trying to use render :update do |page| > > > > page.replace_html, 'theTable' 'relevant code to replace table'- but I > > > > am unsure how to call the html correctly here to render the changed > > > > table on the webpage? > > > > > Any help here would be greatly appreciated! > > > > > Thanks again > > > > > Pete > > > > > On Nov 12, 11:15 pm, kevinpfromnm <[email protected]> wrote: > > > > > > I'm thinking, move the option list to a named_scope that takes an > > > > > argument, then something like: > > > > > > <table-plus with="&ModelName.by_state(@my_option)" > > > > > part="table_by_state"> > > > > > > Then you should be able to use hobo's part mechanism but you'll have > > > > > to poke a little to see how to make it update a part from JS. > > > > > > On Nov 12, 3:54 am, Pete <[email protected]> wrote: > > > > > > > Hi, > > > > > > > I am trying to update a page I have which displays a table of data, > > > > > > but which I would like to dynamically update depending on what is > > > > > > selected in the <select-input> field. > > > > > > > I have a controller with a method containing the table plus info - > > > > > > but > > > > > > in my view, I would like to dynamically change the content of the > > > > > > table plus, I would imagine I could change something here....... > > > > > > > <table-plus with="&@myOption" fields="field1, field2etc" > > > > > > > > where myOption is the result of the select-input field, > > > > > > > <select-input options"&[['Latest', '@latestFinished'], ['All', > > > > > > '@allFinished'] ]", onchange="update @myOption" /> > > > > > > > @latestFinished, and @allFinished are defined in my Controller using > > > > > > my own named_scopes to gather the relevant data. I realise my select > > > > > > input is probably completely wrong, but is there something along > > > > > > these > > > > > > lines that will work?- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
