I have two select menus on a line. The first updates the second:
library: library_select album: album_select
So when you pick a library, the album_select is automatically updated to
show the relevant choices. This is done using ajax. While the ajax request
is loading, I switch the album_select with a loading_select, which is a
disabled select menu with only one choice: "loading...". Now, it
updates
everything fine. But when the album_select is updated, it drops down to a
new line. It is acting like a block, rather than the inline that I want it.
When the loading_select replaces the album_select, it stays inline. But
thats not the case once the album_select is finished loading. What is the
difference between replace_html and :update? What am I missing? I
don''t
see much about this in the docs. Here''s the code.
HTML:
<span>
library: <%= library_select_all %>
album: <span id="album_select"><%= album_select_all
%></span>
</span>
helpers:
def library_select_all
choices= [[''All'', -1]]
choices+= @libraries.collect { |l| [l.title, l.id] }
select "library", "id", choices, {}, {:id =>
"library_select", :onchange
=> "#{
remote_function(
:update => "album_select",
:url => { :action => "album_select"},
:with => "''library_id=''+value",
:loading => show_loading_select
)
}"}
end
def album_select_all
@albums= Album.find(:all, :order => "title")
choices= [[''All'', -1]]
choices+= @albums.collect { |l| [l.title, l.id] }
select "album", "id", choices, {}, {}
end
def show_loading_select
update_page do |page|
page.replace_html "album_select", loading_select
end
end
def loading_select
"<select id=\"loading_select\"
DISABLED><option>loading...</option></select>"
end
Thanks,
Ryan
--
View this message in context:
http://www.nabble.com/Updating-html-breaks-my-interface-t1724267.html#a4684543
Sent from the RubyOnRails Users forum at Nabble.com.
I got it. I was just stupid. Apparently my call to album_select was rendering the layout as well. That''s why it was acting as a block. Sorry. Ryan Wuher wrote:> > I have two select menus on a line. The first updates the second: > > > library: library_select album: album_select > > So when you pick a library, the album_select is automatically updated to > show the relevant choices. This is done using ajax. While the ajax > request is loading, I switch the album_select with a loading_select, which > is a disabled select menu with only one choice: "loading...". Now, it > updates everything fine. But when the album_select is updated, it drops > down to a new line. It is acting like a block, rather than the inline > that I want it. When the loading_select replaces the album_select, it > stays inline. But thats not the case once the album_select is finished > loading. What is the difference between replace_html and :update? What > am I missing? I don''t see much about this in the docs. Here''s the code. > > HTML: > > <span> > library: <%= library_select_all %> > album: <span id="album_select"><%= album_select_all %></span> > </span> > > helpers: > > def library_select_all > choices= [[''All'', -1]] > choices+= @libraries.collect { |l| [l.title, l.id] } > select "library", "id", choices, {}, {:id => "library_select", > :onchange => "#{ > remote_function( > :update => "album_select", > :url => { :action => "album_select"}, > :with => "''library_id=''+value", > :loading => show_loading_select > ) > }"} > end > > def album_select_all > @albums= Album.find(:all, :order => "title") > choices= [[''All'', -1]] > choices+= @albums.collect { |l| [l.title, l.id] } > select "album", "id", choices, {}, {} > end > > def show_loading_select > update_page do |page| > page.replace_html "album_select", loading_select > end > end > > def loading_select > "<select id=\"loading_select\" > DISABLED><option>loading...</option></select>" > end > > > > Thanks, > Ryan > >-- View this message in context: http://www.nabble.com/Updating-html-breaks-my-interface-t1724267.html#a4684746 Sent from the RubyOnRails Users forum at Nabble.com.