I would move it to a helper
def vendor_name_selector
select 'service_record', 'vendor_name',
vendor_name_select_options(@customer_id), {}, { :onchange =>
remote_function(:url => {:action=>:ajax_select_vendor}, :with =>
'Form.Element.serialize(this)') }
end
Then, its a simple..
= vendor_name_selector
Easy to read! More maintainable!
-hampton.
On 3/7/07, Larry Kelly <[EMAIL PROTECTED]> wrote:
>
> Thanks, I'll try that.
> -L
>
> On Mar 7, 11:09 am, Chris Abad <[EMAIL PROTECTED]> wrote:
> > Ah, here you go:
> >
> > :onchange is an html_option. Here's the syntax for select:
> > select(object, method, choices, options={}, html_options={})
> >
> > So you need to do this:
> >
> > = select 'service_record', 'vendor_name', vendor_name_select_options
> > (@customer_id), {}, { :onchange => remote_function(:url =>
> > {:action=>:ajax_select_vendor}, :with => 'Form.Element.serialize
> > (this)') }
> >
> > Notice the empty hash in there to represent the options.
> >
> > On Mar 7, 2007, at 11:01 AM, Larry Kelly wrote:
> >
> >
> >
> > > The ":onchange ... part is not being output to the browser"
> > > -L
> >
> > > On Mar 7, 10:17 am, Chris Abad <[EMAIL PROTECTED]> wrote:
> > >> HAML's involvement in that code looks pretty minimal. I think if
> > >> there is any refactoring to be done, it has more to do w/ the Rails
> > >> code than the HAML. On that note, I don't see anything necessarily
> > >> wrong with that code. If you find yourself typing that multiple times
> > >> throughout your views, it would probably help to extract most of that
> > >> into a helper.
> >
> > >> On Mar 7, 2007, at 10:12 AM, Larry Kelly wrote:
> >
> > >>> I'm attaching an AJAX event call to a select tag. The line looks
> > >>> bad.
> > >>> Is there better way to code this?
> >
> > >>> = select 'service_record', 'vendor_name',
> > >>> vendor_name_select_options(@customer_id), :onchange =>
> > >>> remote_function(:url=>
> > >>> {:action=>:ajax_select_vendor}, :with=>'Form.Element.serialize
> > >>> (this)')
> >
> > >>> - Larry
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" 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/haml?hl=en
-~----------~----~----~----~------~----~------~--~---