Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

Monday, March 26, 2007

AJAX state_select

After downloading the state_select plugin for rails.
I put in a little extra work to make the state select AJAX updated.
The address form looks like:

<%= state_select 'address', 'state', country='US' %>

...
<%= country_select 'address', 'country' %>
<%= observe_field :address_country, :frequency=>0.5,
:update=>"state_select",
:url=> {:action=>'state_select', :only_path=>false},
with=>"'country=' + encodeURIComponent(value)" %>

Where the AJAX calls into a partial form:

<% if params[:country] == "United States" %>
<%= state_select 'address', 'state', country='US' %>
<% elsif params[:country] == "India" %>
<%= state_select 'address', 'state', country='INDIA' %>
<% elsif params[:country] == "Canada" %>
<%= state_select 'address', 'state', country='CANADA' %>
<% elsif params[:country] == "Australia" %>
<%= state_select 'address', 'state', country='AUSTRALIA' %>
<% elsif params[:country] == "Spain" %>
<%= state_select 'address', 'state', country='SPAIN' %>
<% elsif params[:country] == "Uganda" %>
<%= state_select 'address', 'state', country='UGANDA' %>
<% elsif params[:country] == "France" %>
<%= state_select 'address', 'state', country='FRANCE' %>
<% elsif params[:country] == "Germany" %>
<%= state_select 'address', 'state', country='GERMAN' %>
<% else %>
<%= text_field 'address', 'state', :class=>"text" %>
<% end %>

I have posted to their blog to see if the state_select could be updated so there was no translation needed between the "country" from select_country and the "country" parameter passed into the state_select. It would be also nice to return a text field if there is no state list for the given country.
This would mean the partial code would just be:

<%= state_select 'address', 'state', params[:country].uppercase %>

Saturday, January 07, 2006

Inline HTML editors

Just found a neat HTML editor that I will try out at the concordtv web site. Seems really neat: http://tinymce.moxiecode.com/
It was mention in the comparison chart at: http://www.geniisoft.com/showcase.nsf/WebEditors

Saturday, November 19, 2005

Nice UI for a milk site

The UI in this site is really neat and easy to use. It almost feels like a normal application rather than a web site. It is really amazing that only two Australians wrote it. The web tools these days are really amazing.

http://www.rememberthemilk.com