Re: [Lift] onSubmitUnit or ajaxSubmit doesn't work

82 views
Skip to first unread message

David Pollak

unread,
Dec 27, 2012, 2:49:56 PM12/27/12
to lif...@googlegroups.com
A few things...

First, if you're using Html5, then the </input> tag is not helping things.

Second, there's no target for your form, so it's unlikely that it's being submitted to the server.

Please read through http://simply.liftweb.net/index-Chapter-4.html#toc-Chapter-4 It should help.

On Thu, Dec 27, 2012 at 11:41 AM, <ivans...@gmail.com> wrote:
I'm new to Lift and trying to run a very basic example. The transformations work, but when I click the submit button, nothing happens. No idea why.

This is the HTML:

<div class="lift:MySnippet.test" form="POST">
 
<div>START---------------------------------------------------</div>
 
<div id="name_input"></div>
 
<input id="testsubmit" type="submit" value="x"></input>
 
<div>END---------------------------------------------------</div>
</div>

This is the snippet:

class MySnippet {
 
 
def test = {
 
var itemName = "item name"
 
 
"#name_input" #> SHtml.text(itemName, itemName = _) &
 
"#testsubmit" #>
 
SHtml.ajaxSubmit("label", () => println("test"))
// SHtml.onSubmitUnit(() => println("test"))
 
}
}


"label" works. But println seems not to be executed.

Thanks in advance.

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
 
 



--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net

pelagic

unread,
Dec 27, 2012, 3:45:09 PM12/27/12
to lif...@googlegroups.com
Also take a look at SHtml.makeFormsAjax.  Note: you're going to need <form> tags for this to work

your snippet would look like

class MySnippet {
 
 
def test = { render andThen SHtml.makeFormsAjax }

 def test = {

 
  var itemName = "item name"
 
 
  "#name_input" #> SHtml.text(itemName, itemName = _) &
 
  "#testsubmit" #> SHtml.ajaxSubmit("label", () => println("test"))

pelagic

unread,
Dec 27, 2012, 3:48:34 PM12/27/12
to lif...@googlegroups.com
sorry typos in my code

class MySnippet {
 
 
def test =
{ render andThen SHtml.makeFormsAjax }

 def render = {

ivans...@gmail.com

unread,
Dec 28, 2012, 1:29:42 PM12/28/12
to lif...@googlegroups.com
The form was missing either target, or in the case of Ajax: 

 <form class="lift:form.ajax">...</form>
 
Was oriented by some code snippets from "Lift in action". Probably wrongly combined.

The examples from  http://simply.liftweb.net/ got me running, thanks!
Reply all
Reply to author
Forward
0 new messages