How to use CSS selector to change form action attribute

459 views
Skip to first unread message

Felipe Kamakura

unread,
Jan 12, 2011, 8:58:31 PM1/12/11
to Lift
Hello everyone,

Suppose I have the following snippet:

<form id="myform" class="lift:MySnippet?form=post>
...
</form>

In my Snippet I would like to specify the form's action attribute, so
I tried the following

"#myform [action]" #> ( S.uri + "?myParam=" + S.param("myParam")
openOr "")

But the action attribute is not replaced. Is there a way to specify it
in my Snippet?

Thanks!

David Pollak

unread,
Jan 12, 2011, 10:45:35 PM1/12/11
to lif...@googlegroups.com
On Wed, Jan 12, 2011 at 5:58 PM, Felipe Kamakura <felipek...@gmail.com> wrote:
Hello everyone,

Suppose I have the following snippet:

<form id="myform" class="lift:MySnippet?form=post>
 ...
</form>

In my Snippet I would like to specify the form's action attribute, so
I tried the following

"#myform [action]" #> ( S.uri + "?myParam=" + S.param("myParam")
openOr "")


Yeah, remove the form=post... that sets the action and the method after the snippet is processed.
 
But the action attribute is not replaced. Is there a way to specify it
in my Snippet?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

fmpwizard

unread,
Jan 12, 2011, 10:46:17 PM1/12/11
to Lift
My answer my be totally off as I'm still new to Lift but if you use
class="lift:MySnippet?form=post>, lift will assign the action to the
current page, if you try to change that, maybe you don;t want
MySnippet to handle the post data, in which case you may want to omit
the attribute

class="lift:MySnippet?form=post" and just use a regular html form and
in the action



This works for me:

<lift:MySnippet.renderresults>
<form id="myform" action="menos">
diego
</form>
</lift:MySnippet.renderresults>


===============

class MySnippet {

def renderresults = {
"#myform [action] " #> "/foo"
}

}


I hope this helps

Diego

Felipe Kamakura

unread,
Jan 13, 2011, 8:23:58 AM1/13/11
to Lift
Cool, thank you guys!
Reply all
Reply to author
Forward
0 new messages