Forum: Ruby on Rails Updating html breaks my interface

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2c3e9116fabc3e9f09927d1ffa8bf9e3?d=identicon&s=25 Wuher (Guest)
on 2006-06-02 20:26
(Received via mailing list)
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-inte...
Sent from the RubyOnRails Users forum at Nabble.com.
2c3e9116fabc3e9f09927d1ffa8bf9e3?d=identicon&s=25 Wuher (Guest)
on 2006-06-02 20:39
(Received via mailing list)
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:
> updates everything fine.  But when the album_select is updated, it drops
> 	album: <span id="album_select"><%= album_select_all %></span>
>         :update => "album_select",
>     choices+= @albums.collect { |l| [l.title, l.id] }
>     "<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-inte...
Sent from the RubyOnRails Users forum at Nabble.com.
This topic is locked and can not be replied to.