Well, first off, there is an error in your ruby code.

If you notice this part... #{event.id, url_for(...)}. The #{} operator
should not have a comma in it. I believe you meant the line to be....
"event_toggle_occurrences(#{event.id}, #{url_for(:action =>
"occurrences", :id => event)});"

That should work, but may i recommend this?

def toggle_events_link(event)
  open :a,
          :onclick=>"event_toggle_occurrences(#{event.id},
#{url_for(:action => "occurrences", :id => event)});",
          :title=>"Click to view all occurrences"
end

And in the Haml view:

  = toggle_events_link(event)

Just makes for much cleaner and easier to read code.

-hampton.

PS: the "open" helper only works on trunk.


On 3/24/07, Genevate <[EMAIL PROTECTED]> wrote:
>
> I'm having the saem issue trying to do somehting very similar.
>
> %a{:href=>
> "javascript:void(0)", :onclick=>"event_toggle_occurrences(#{event.id,
> url_for(:action => "occurrences", :id => event)});", :title=>"Click to
> view all occurrences"}
>
> Any luck with this?
>
> Chris-
>
>
> On Mar 9, 3:53 pm, "s.ross" <[EMAIL PROTECTED]> wrote:
> > The error message is:
> >
> > (eval):43:in `compile': compile error
> > (eval):34: parse error, unexpected '=', expecting ')'
> > _hamlout.open_tag("td", 1, nil, false, "", {:class => @row_class}=
> > check_box_tag :approved, 1, post_list_row.approved, {:onclick => "new
> > Ajax.Request('#{url_for(:controller => 'posts', :action =>
> > 'toggle_approved', :id => post_list_row[:id])}')"}, nil, false)
> >                                                                    ^
> > (eval):34: parse error, unexpected ')', expecting kEND
> >
> > Extracted source (around line #12):
> >
> > 9:   %td{:class => @row_class}
> > 10:     = post_list_row.posted_by
> > 11:   %td{:class => @row_class}= check_box_tag :approved, 1,
> > post_list_row.approved, {:onclick => "new Ajax.Request('#{url_for
> > (:controller => 'posts', :action => 'toggle_approved', :id =>
> > post_list_row[:id])}')"}
> > 12:   %td{:class => @row_class}= link_to(pluralize
> > (post_list_row.comments.count(:conditions => 'approved = 0'),
> > 'comment'), :controller => 'comments', :action => 'list')
> >
> > Strange, huh?
> >
> > Steve
> >
> > On Mar 9, 2007, at 10:42 AM, Nathan Weizenbaum wrote:
> >
> >
> >
> > > I don't think it should be failing... what happens?
> >
> > > - Nathan
> >
> > > s.ross wrote:
> > >> I have a case where this works:
> >
> > >> %td{:class => @row_class}
> > >>    = check_box_tag :approved, 1, post_list_row.approved, {:onclick =>
> > >> "new Ajax.Request('#{url_for(:controller => 'posts', :action =>
> > >> 'toggle_approved', :id => post_list_row[:id])}')"}
> >
> > >> But this fails:
> >
> > >> %td{:class => @row_class}= check_box_tag :approved, 1,
> > >> post_list_row.approved, {:onclick => "new Ajax.Request('#{url_for
> > >> (:controller => 'posts', :action => 'toggle_approved', :id =>
> > >> post_list_row[:id])}')"}
> >
> > >> I prefer the latter construct. Any reason it might be failing that
> > >> I'm not seeing?
> >
> > >> Thanks,
> >
> > >> Steve
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to