OK, seems like I have to learn a little more about Scala so I can
override the ajaxText method, right? Here it is in the docs:

def ajaxText(value: String, func: String => JsCmd): Elem = ajaxText_*
(value, SFuncHolder(func))

When I fumble around, it won't compile, because I'm just not doing it
right. My project is a hobby, not mission-critical, so I'm under no
pressure.

For now, I will change to an ajaxForm, but the learning is all good,
and if you want to keep teaching, I will listen!

Thanks for your patience...


On Aug 18, 12:41 pm, "marius d." <marius.dan...@gmail.com> wrote:
> Having
>
> def ajaxText(value: String, jsFunc: Call, func: String => JsCmd)
>
> jsFunc parameter is a Call which is defined as:
>
> case class Call(function: String, params: JsExp*) extends JsExp
>
> So by this you represent a javascript function invocations.
>
> So assuming somewhere you have a javascript function like:
>
> function myFunc(myParam, callback)  {
>
>    // do some logic
>    callback()
>
> }
>
> in the snippet we have something like:
>
> ajaxText(task.dueOn.toString,
>               Call("myFunc", Str("some_param_value"))
>                v => { task.dueOn(v.toLong).save; reDrawTasks();})
>
> As you can see we called Call("myFunc", Str
> ("some_param_value")) .. .we provided the JS function name and one
> parameter. Lift will add the second parameter which is the callback
> function. This callback function represents the actual ajax call and
> since it is a callback you can invoke it whenever you want inside
> 'myFunc' javascript function. In other words you can defer the actual
> ajax call as you see fit.
>
> Now myFunc function declaration can be:
> 1. In your own .js file
> 2. Written in the <script> tag inside your html
> 3. Generate using Lifts' JS absctrations using JsCmds.Function()
> object such as:
>
>   JsCmds.Function("MyFunc", List("myParam", "callback"),
> a_JsCmd_expression_which_is_the_function_body)
>
> The main point in all this is that you can defer the actual ajax call.
> You know better if this fits your case.
>
> Br's,
> Marius
>
> On Aug 18, 10:21 pm, g-man <gregor...@gmail.com> wrote:
>
> > No, this is the old way ...I am unsure how to invoke the ajax method
> > -- could you enlighten me?
>
> > On Aug 17, 12:26 pm, "marius d." <marius.dan...@gmail.com> wrote:
>
> > > I don't see in your code the use of the overloaded ajaxText that I
> > > posted. Have you tried it?
>
> > > Marius
>
> > > On Aug 17, 10:20 pm, g-man <gregor...@gmail.com> wrote:
>
> > > > OK, thanks for checking back...
>
> > > > Snippet:
> > > > swappable(<span class='dueon'>{task.dueOn.toString}</span>,
> > > >               <span class='chgDueon'>{ajaxText(task.dueOn.toString,
> > > >                   v => { task.dueOn(v.toLong).save; reDrawTasks();
> > > >                   }) % ("size" -> "10")}</span>)
>
> > > > JS:
> > > > $chgDueon // jQuery selection for text field
> > > >     .datepicker({dateFormat:'m-d-yy', minDate: +1})
> > > >     .blur(function(){$chgDueon.val(parseDate($chgDueon.val()));});
> > > > // works well to pick a new date and change it to millis for save
>
> > > > Emitted XHTML:
> > > > <span>
> > > >    <span class="dueon" id="F111290299287IBE"
> > > >        onclick="jQuery('#'+'F111290299287IBE').hide();
> > > >           jQuery('#'+'F1112902992880KN').show().each(function(i) {
> > > >               var t = this; setTimeout(function() { t.focus(); },
> > > > 200);});return false;;">
> > > >        1248493271843</span>
> > > >    <span style="display: none" id="F1112902992880KN"
> > > >       onblur="jQuery('#'+'F111290299287IBE').show();
> > > >           jQuery('#'+'F1112902992880KN').hide();">
> > > >       <input onblur="lift_ajaxHandler('F111290299286DL1=' +
> > > >          encodeURIComponent(this.value), null, null)"
> > > >          type="text" value="1248493271843"
> > > >          onkeypress="lift_blurIfReturn(event)" size="10" />
> > > >     </span>
> > > > </span>
>
> > > > So, all the parts work well together, but Lift's ajax just takes off
> > > > too quickly, and cannot read the new value.
>
> > > > On Aug 16, 11:02 pm, "marius d." <marius.dan...@gmail.com> wrote:
>
> > > > > You can probably use this definition of ajaxText:
>
> > > > > def ajaxText(value: String, jsFunc: Call, func: String => JsCmd)
>
> > > > > See the jsFunc parameter. Essentially you are specifying your function
> > > > > call that may have one parameter. To your parameter list List we'll
> > > > > add a new parameter which is the ajax invocation function. In other
> > > > > words your code gets that function that does the ajax call meaning
> > > > > that you have the control over when the ajax call is made.
>
> > > > > Br's,
> > > > > Marius
>
> > > > > On Aug 17, 8:55 am, "marius d." <marius.dan...@gmail.com> wrote:
>
> > > > > > Would you please post a code snippet with what you're doing? (a
> > > > > > minimalistic example)
>
> > > > > > Br's,
> > > > > > Marius
>
> > > > > > On Aug 17, 7:41 am, g-man <gregor...@gmail.com> wrote:
>
> > > > > > > I am moving nicely with my 'save all dates as millis and let the
> > > > > > > client localize for display' project, learning while enhancing the
> > > > > > > ToDo sample app.
>
> > > > > > > I have added a 'dueOn' field, and that is displayed as swappable
> > > > > > > ajaxText, similar to the other fields in the tutorial.
>
> > > > > > > I have enabled datepicker for the ajaxText field via jQuery, and 
> > > > > > > have
> > > > > > > a parsing function attached an event listener, so when datepicker
> > > > > > > finishes, the date is converted to millis, ready for Lift to send 
> > > > > > > back
> > > > > > > to the server and save.
>
> > > > > > > So far, all good.
>
> > > > > > > The problem is that Lift's ajax starts ('onblur') before it has a
> > > > > > > chance to see the new date value, so the new value is never saved.
>
> > > > > > > What I need is a way to tell Lift to wait until after my parser 
> > > > > > > has
> > > > > > > had a chance to write the changed value.
>
> > > > > > > I like the ajax style, so I don't want to make a 'submit' form, 
> > > > > > > and
> > > > > > > 'onchange' won't do it either, because the value is actually 
> > > > > > > changed
> > > > > > > twice (once to a formatted date, once to millis).
>
> > > > > > > What I need is some way to say, 'OK to start ajax now'!
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to