You have to add a pipe onto the last line.
However, I would recommend not putting these into your views. Put this
into a helper. Its not going to make your application less lines, but
it will make it more readable
= check_time_link
def check_time_link
link_to_remote "Check Time",
:update => 'current_time',
:url => {:action => 'get_time'},
:before => "$('indicator').show()",
:success => "$('current_time').visualEffect('highlight')",
:failure => "alert('There was an error. ')",
:complete => "$('indicator').hide()"
end
That has several advantages. None of which are less-lines-of-code.
Anyone coming to your page will instantly know what a link does...
check_time_link (obviously in this example, that's a limited
advantage, since you can read the label of the link_to). And, it makes
sure that your view is consice. That is the most important part.
Views with a lot of Ajax tend to be *incredibly* hard to see the
actual structure of the page and worry about that. The Ajax gets right
in the way. So, that's why I highly recommend breaking anything like
that out into Helper methods, so that you can clear out the clutter
and see exactly what your application is doing. Moreover, if your link
for checking time isn't working, then just go right into the helper,
because you know that it will be there. And it will be nicely named
too.
-hampton.
On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm reading thru Ajax on Rails and trying to convert Scott Raymond's
> RHTML to Haml. Everything was going well until I got to:
>
> <%= link_to_remote "Check Time",
> :update => 'current_time',
> :url => {:action => 'get_time'},
> :before => "$('indicator').show()",
> :success => "$('current_time').visualEffect('highlight')",
> :failure => "alert('There was an error. ')",
> :complete => "$('indicator').hide()" %>
>
> which I attempted to render as:
>
> = link_to_remote "Check Time", |
> :update => 'current_time', |
> :url => {:action => 'get_time'}, |
> :before => "$('indicator').show()", |
> :success => "$('current_time').visualEffect('hightlight')", |
> :complete => "$('indicator').hide()"
>
> when I hit that page I get:
>
> (eval):12:in `compile': compile error
> (eval):7: parse error, unexpected '\n', expecting tASSOC
>
> I've tried various permutations but without success.
>
> Is this a bug or am I, being new to Haml, doing something wrong?
>
> Thanks ... WkH
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---