[Catalyst] Http::Prototype

Will Smith willbelair at yahoo.com
Fri Nov 18 04:16:50 CET 2005


thanks John,
   
  I read the doc of html::prototype, and followed your code example, but still missing a piece. I am not very familiar with jvscript as well as this prototype, so is it possible for you to make it a bit clearer. 
  I have myapp::M::CDBI::Country and myapp::M::CDBI::City, on the template, I have 2 select boxes, one for country and another one for city (country: countryid, countryname / city: cityid, cityname, countryid)
   
  [% USE table_class = Class('myapp::M::CDBI::Country') %]
  <select id="selectA" size="1" name="country" value="[% object.countryid %]" onchange="???????">
      [% FOR object = table_class.retrieve_all %]<option>[% object.countryname %]</option>[% END %]</select>
   
  [% WHILE (city = mycity.next) %]
  <select id="selectB" size="1" name="city"><option>[% city.cityname %]</option>[% END %]</select>
   
  [% c.prototype.observe_field('selectA',{
  url      => '/ajax/doAction',
  with     => "'action='+document.getElementById('selectA').value",
  update   => 'selectA_result',
  complete => "document.getElementById('selectB').selectedIndex = document.getElementById('selectA_result').innerHTML"
}) %]

  ----------
  in the myapp::C::City, I have a sub:
   
  sub doAction : Local {
  my ($self,$c) = @_;
    $c->stash->{mycity} = myapp::M::CDBI::City->search(countryid=>$c->req->param('action'));
  $c->stash->{template} = 'selectcity.tt';
}
-----------
   
  My question is:
  - How the javascript (prototype.observe_field) get trigger? I need to have something in the OnChange in the div id=SelectA.
   
  - Will I get the right result if I do the search and return the result as a stash of object?
   
  Thanks for all your help.
   
  Will


		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051117/ad31a08a/attachment.htm


More information about the Catalyst mailing list