Form does not want to send

17 views
Skip to first unread message

greekscala

unread,
Dec 28, 2009, 6:01:18 PM12/28/09
to Lift
Hello Lift people!

I am experimenting with Lift for building a web application.
I read alot on the list on the ajax subject and I think I get more
familiar with.

I try to get a form submittet with ajax. I want an easy solution
without much
code writing. I tried the following suggestion as found here in the
list:

SHtml.ajaxForm(
bind("bookmark", xml,
"url" -> SHtml.text(url, url = _),
"submit" -> SHtml.submit("add", addBookmark)
) ++ SHtml.hidden(addBookmark)
)

I am using a StatefulSnippet. My little template:

<lift:surround with="default" at="col3">
<div id="addb">
<lift:Bookmark.add>
<bookmark:url />
<bookmark:submit />
</lift:Bookmark.add>
</div>
</lift:surround>

The form gets rendered but not submitted when the "add" button is
clicked.
I have a freshly build 1.1-snapshot and using simple-build-tool
(running jetty).

Do not understand it. Without Ajax it works.

with best regards

Marius

unread,
Dec 29, 2009, 3:15:43 AM12/29/09
to Lift
Can you paste the html generated? ... Do you see any errors in
FireBug?

Br's,
Marius

Timothy Perrett

unread,
Dec 29, 2009, 4:18:45 AM12/29/09
to lif...@googlegroups.com
You need to change the html to:

<lift:Bookmark.add form="post">

Otherwise lift does not render for the form element.

Cheers, Tim

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

greekscala

unread,
Dec 29, 2009, 7:12:11 AM12/29/09
to Lift
Hello,

> You need to change the html to:
>
> <lift:Bookmark.add form="post">
>
> Otherwise lift does not render for the form element.

No the forms are rendered in html. I think the form="post" is only
needed when ajaxForm is not used.

But I see now in the Firebug Console that the liftajax cannot find
jQuery.

jQuery is not defined
http://localhost:8080/ajax_request/liftAjax.js
Line 157

jQuery is not defined
http://localhost:8080/bookmarks/add
Line 105

For the second error this is the generated JS in my html:
<script type="text/javascript">
104 // <![CDATA[
105 jQuery(document).ready(function() {liftAjax.lift_successRegisterGC
();});
106 var lift_page = "F1160735200508JPL";
107 // ]]>
108 </script>

The liftajax.js file is found.

The lift version I am using is a freshly build 1.1-snapshot of the
lift-base module.

with best regards

greekscala

unread,
Dec 29, 2009, 7:33:15 AM12/29/09
to Lift
I see now that I get the same error, that jQuery is not found
with lift 1.0 too. That is confusing.

Timothy Perrett

unread,
Dec 29, 2009, 7:35:45 AM12/29/09
to lif...@googlegroups.com
As marius asked, please paste more html or link to the application online.

Without seeing more, its near impossible to debug.

Cheers, Tim

greekscala

unread,
Dec 29, 2009, 7:43:55 AM12/29/09
to Lift
This is the generated head:

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Test</title>
<link type="text/css" rel="stylesheet" href="/css/my_layout.css">
</link>
<script type="text/javascript" src="/ajax_request/liftAjax.js">
</script>
</head>

This is the generated form in a simple div element:

<div id="addsf">
<form id="F392208970316G4M" action="javascript://"
onsubmit="lift_ajaxHandler(jQuery('#'+'F392208970316G4M').serialize(),
null, null);return false;">
<input type="text" name="F392208970313SOO" value=""/>
<input type="submit" name="F392208970314N0V" value="add"/>
<input type="hidden" name="F392208970315CPR" value="true"/>
</form>
</div>

And this is a generated script block at the bottom of the page:

<script type="text/javascript">
//
jQuery(document).ready(function() {lift_successRegisterGC();});
var lift_page = 'F392208970312QQE';
//
</script>

with best regards

Timothy Perrett

unread,
Dec 29, 2009, 8:08:49 AM12/29/09
to lif...@googlegroups.com
It cant find JQuery, because, err, you have referenced it...

You need to add:

<script type="text/javascript" src="/classpath/jquery.js"></script>

to your <head> element

Cheers, Tim

greekscala

unread,
Dec 29, 2009, 8:44:25 AM12/29/09
to Lift
I dont think I have to take care to reference jQuery myself for lift.
Lift should insert the version it needs automatically.

Ok I can workaround this by inserting a jquery reference, but I see
that jquery is in the lift sources.

The LiftBook states that by default the LiftRules.jsArtifacts variable
is
pointing to use jQuery by default.

with best regards

Marius

unread,
Dec 29, 2009, 8:54:59 AM12/29/09
to Lift
When you create a lift project using one of the Lift archetypes, the
html templates include a reference to JQuery such as: <script

type="text/javascript" src="/classpath/jquery.js"></script>

Lift does not inject jquery reference in html head. I don't think it
should as one could use Lift with YUI or other Lift framework. We
could probably create a small builtin snippet that does that but I
don't see lots of gains but probably would be helpful.

Br's,
Marius

greekscala

unread,
Dec 29, 2009, 9:02:07 AM12/29/09
to Lift
Ok I did not use the archetypes. But I did not read this elsewhere.
Would be good to have this noted in the lift book or in the lift wiki.

I will post a comment on the liftbook group.

I will test it again with jQuery referenced.

with best regards

greekscala

unread,
Dec 29, 2009, 9:35:23 AM12/29/09
to Lift
Test it and it works.

Thanks you guys.

with best regards

David Pollak

unread,
Dec 29, 2009, 6:14:27 PM12/29/09
to lif...@googlegroups.com
On Tue, Dec 29, 2009 at 5:44 AM, greekscala <hellec...@gmail.com> wrote:
I dont think I have to take care to reference jQuery myself for lift.
Lift should insert the version it needs automatically.

Lift used to do this and people got in a huff about "Lift requires jQuery".  Further, the cost of analyzing the outgoing page for the expected JavaScript libraries would be high... balance that with the fact that you're the first person that's had this particular issue in the last 4 months... I think we've struck the right balance.
 



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

Anton K

unread,
Nov 8, 2016, 8:48:41 AM11/8/16
to Lift, feeder.of...@gmail.com
I'm having the same issue half a decade later. Just to be clear, the proper solution is referencing jQuery in the HTML templates, and not setting some variable in Boot?

Best,
Anton

Diego Medina

unread,
Nov 8, 2016, 9:22:23 AM11/8/16
to Lift, David Pollak
Hi Anton,

if you are still having an issue, please start a new thread, this helps us better help you.

Thanks

Diego

--
--
Lift, the simply functional web framework: http://liftweb.net
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
http://blog.fmpwizard.com/
Reply all
Reply to author
Forward
0 new messages