Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Need help with the Jquery script in Lift
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
sailormoontw@gmail.com  
View profile  
 More options Aug 23 2011, 9:42 pm
From: "sailormoo...@gmail.com" <sailormoo...@gmail.com>
Date: Tue, 23 Aug 2011 18:42:11 -0700 (PDT)
Local: Tues, Aug 23 2011 9:42 pm
Subject: Need help with the Jquery script in Lift
I remember I wrote another thread about this, and someone replied me
to write the codes. But I can't find the coding standard in Assembla,
so I write the codes with my style first.

1. TestForm.snippet
import _root_.net.liftweb._
import http._
import SHtml._
import util._
import Helpers._

class TestForm extends StatefulSnippet {
  def dispatch = {
    case _ => render
  }

  def render =  "type=submit" #> SHtml.onSubmitUnit(() =>
println("TEST"))

}

2. test_1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <body class="lift:content_id=main">
  <div id="main" class="lift:surround?with=default;at=content">
  <div id="form" class="lift:TestForm?form=post">
    <input id="submit" type="submit" value=" S U B M I T "/>
  </div>
  </div>
  </body>
</html>

3. test_2.html (same with test_1.html but with the script in the
header )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <body class="lift:content_id=main">
  <div id="main" class="lift:surround?with=default;at=content">
  <head>
    <script>
      <script id="jquery" src="http://ajax.googleapis.com/ajax/libs/
jquery/1.6.1/jquery.min.js"
          type="text/javascript"></script>
      // <![CDATA[
        jQuery(document).ready(function(){
          jQuery("form").submit(function(){
            jQuery(":submit").attr("disabled", "disabled");
          });
        });
      // ]]>
    </script>
  </head>
  <div id="form" class="lift:TestForm?form=post">
    <input id="submit" type="submit" value=" S U B M I T "/>
  </div>
  </div>
  </body>
</html>

4. My problem is, test_1 and test_2 calling the same StatefulSnippet
(TestForm), but in test_2 adding the script that prevents clicking
submit more than once, resulting the submit button doesn't work.
( Note : press submit in test_1.html I got the TEST message in
console, but not test_2.html )

  Why? And what should I do to actually adding the javascript code to
work with Lift ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diego Medina  
View profile  
 More options Aug 23 2011, 10:34 pm
From: Diego Medina <di...@fmpwizard.com>
Date: Tue, 23 Aug 2011 22:34:42 -0400
Local: Tues, Aug 23 2011 10:34 pm
Subject: Re: [Lift] Need help with the Jquery script in Lift
There is a Lift way of doing what you are trying to do,

from https://github.com/lift/framework/blob/master/web/webkit/src/main/sca...

  /**
   * If you bind functions (i.e. using SHtml helpers) inside the
closure passed to callOnce,
   * after your function is invoked, it will be automatically removed
from functions cache so
   * that it cannot be invoked again.
   */
  def callOnce[T](f: => T): T = {
    autoCleanUp.doWith(true) {
      f
    }
  }

Hope it helps

P.S. the code posting rules are here:

http://www.assembla.com/spaces/liftweb/wiki/Posting_example_code

Regards,

  Diego

On Tue, Aug 23, 2011 at 9:42 PM, sailormoo...@gmail.com

--
Diego Medina
Web Developer
(305) 788-4954
di...@fmpwizard.com
http://www.fmpwizard.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sailormoontw@gmail.com  
View profile  
 More options Aug 24 2011, 5:13 am
From: "sailormoo...@gmail.com" <sailormoo...@gmail.com>
Date: Wed, 24 Aug 2011 02:13:30 -0700 (PDT)
Local: Wed, Aug 24 2011 5:13 am
Subject: Re: Need help with the Jquery script in Lift
Thanks for the help, but I would like to ask the javascript code I
wrote is executed in the client first, and after that then it would be
posted to the server, why the server can't run the submit ?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diego Medina  
View profile  
 More options Aug 24 2011, 3:36 pm
From: Diego Medina <di...@fmpwizard.com>
Date: Wed, 24 Aug 2011 15:36:05 -0400
Local: Wed, Aug 24 2011 3:36 pm
Subject: Re: [Lift] Re: Need help with the Jquery script in Lift

Could you post a sample app that shows the problem?

Thanks

Diego
Sent from my cell
On Aug 24, 2011 5:13 AM, "sailormoo...@gmail.com" <sailormoo...@gmail.com>
wrote:

> Thanks for the help, but I would like to ask the javascript code I
> wrote is executed in the client first, and after that then it would be
> posted to the server, why the server can't run the submit ?

> --
> You received this message because you are subscribed to the Google Groups
"Lift" group.
> To post to this group, send email to liftweb@googlegroups.com.
> To unsubscribe from this group, send email to

liftweb+unsubscribe@googlegroups.com.
> For more options, visit this group at

http://groups.google.com/group/liftweb?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chka  
View profile  
 More options Apr 24 2012, 4:47 pm
From: Chka <chii...@gmail.com>
Date: Tue, 24 Apr 2012 13:47:35 -0700 (PDT)
Local: Tues, Apr 24 2012 4:47 pm
Subject: Re: Need help with the Jquery script in Lift

Does anybody know how to make a submit button working with javascript code?

Any solution for the problem described above?

Thanks,
Chka


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diego Medina  
View profile  
 More options Apr 24 2012, 11:44 pm
From: Diego Medina <di...@fmpwizard.com>
Date: Tue, 24 Apr 2012 23:44:28 -0400
Local: Tues, Apr 24 2012 11:44 pm
Subject: Re: [Lift] Re: Need help with the Jquery script in Lift

On Tue, Apr 24, 2012 at 4:47 PM, Chka <chii...@gmail.com> wrote:
> Does anybody know how to make a submit button working with javascript code?

Could you be more specific about what you are trying to do? It doesn't
sound lift related, but maybe you meant something different than what
I think.

> Any solution for the problem described above?

I posted an answer to his question, you may want to start a new thread
with your own question.

Regards,

  Diego

> Thanks,
> Chka

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

--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://www.fmpwizard.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »