Lea Viljanen
2007-Feb-20 11:54 UTC
[Masterview-users] How to get :confirm and :post functionality with a mv:link_to?
I have a link in the form of:
<%= link_to ''Destroy'', { :action =>
''destroy'', :id => component },
:confirm => ''Are you sure?'', :post => true %>
in an application I''m converting to use Masterview. However, I
haven''t
found a way to achieve exactly this with mv:link_to. Note, that in my
original application, the :confirm and :post get converted by Rails
framework to a piece of onclick= javascript, but Masterview just adds
the :confirm and :post parameters to the link URL.
I could go through a separate destroy form/page, but I prefer it this
way, it gives direct feedback to user instead of jumping between pages.
Any hints appreciated,
- Lea
--
Lea ''LadyBug'' Viljanen Independent security consultant.
ladybug at iki.fi http://www.lavsecurity.fi/
Jeff Barczewski
2007-Feb-20 16:31 UTC
[Masterview-users] How to get :confirm and :post functionality with a mv:link_to?
On 2/20/07, Lea Viljanen <Lea.Viljanen at cs.helsinki.fi> wrote:> > I have a link in the form of: > > <%= link_to ''Destroy'', { :action => ''destroy'', :id => component }, > :confirm => ''Are you sure?'', :post => true %> > > in an application I''m converting to use Masterview. However, I haven''t > found a way to achieve exactly this with mv:link_to. Note, that in my > original application, the :confirm and :post get converted by Rails > framework to a piece of onclick= javascript, but Masterview just adds > the :confirm and :post parameters to the link URL. > > I could go through a separate destroy form/page, but I prefer it this > way, it gives direct feedback to user instead of jumping between pages. > > Any hints appreciated, > - Lea > > -- > Lea ''LadyBug'' Viljanen Independent security consultant. > ladybug at iki.fi http://www.lavsecurity.fi/ >I will take a look and see whether it is a syntax issue or defect. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070220/90567959/attachment.html
Jeff Barczewski
2007-Feb-20 18:14 UTC
[Masterview-users] How to get :confirm and :post functionality with a mv:link_to?
Lea,
I just added a test to confirm this and it appears to work in the trunk. So
double check your syntax with the test code below and see if maybe it was a
typo.
Otherwise maybe it was something that was recently fixed. I am planning to
push out a new release today so if the below syntax does not work for you on
your version, then the new version should fix it.
def test_link_to_with_post_and_confirm
template = <<-END
<div mv:generate=''foo/bar''>
<a href="#" mv:link_to="{ :action =>
''destroy'', :id => component },
:confirm => ''Are you sure?'', :post =>
true">Destroy</a>
</div>
END
expected = {
''foo/bar'' => "<div><%= link_to(
''Destroy'', { :action => ''destroy'', :id
=> component }, :confirm => ''Are you sure?'', :post =>
true ) %></div>"
}
assert_template_result expected, template
end
Blessings,
Jeff
On 2/20/07, Jeff Barczewski <jeff.barczewski at gmail.com>
wrote:>
> On 2/20/07, Lea Viljanen <Lea.Viljanen at cs.helsinki.fi> wrote:
> >
> > I have a link in the form of:
> >
> > <%= link_to ''Destroy'', { :action =>
''destroy'', :id => component },
> > :confirm => ''Are you sure?'', :post => true
%>
> >
> > in an application I''m converting to use Masterview. However,
I haven''t
> > found a way to achieve exactly this with mv:link_to. Note, that in my
> > original application, the :confirm and :post get converted by Rails
> > framework to a piece of onclick= javascript, but Masterview just adds
> > the :confirm and :post parameters to the link URL.
> >
> > I could go through a separate destroy form/page, but I prefer it this
> > way, it gives direct feedback to user instead of jumping between
pages.
> >
> > Any hints appreciated,
> > - Lea
> >
> > --
> > Lea ''LadyBug'' Viljanen Independent security
consultant.
> > ladybug at iki.fi http://www.lavsecurity.fi/
> >
>
>
> I will take a look and see whether it is a syntax issue or defect.
>
--
Jeff Barczewski, MasterView core team
Inspired Horizons Ruby on Rails Training and Consultancy
Next Ruby on Rails plus JRuby workshop Feb 22-24 St. Louis, MO
http://inspiredhorizons.com/training/rails/index.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/masterview-users/attachments/20070220/00ffbf2c/attachment.html
Lea Viljanen
2007-Feb-20 19:35 UTC
[Masterview-users] How to get :confirm and :post functionality with a mv:link_to?
Jeff Barczewski wrote:> I just added a test to confirm this and it appears to work in the trunk. > So double check your syntax with the test code below and see if maybe it > was a typo.Duh, I had tried different combinations with the closing quotes and braces but apparently not the exactly correct one. So, it works now, thanks! - Lea