perhaps someone know the answer for the following two questions. Google
was not that helpful.
I'm using Lift 2.1/Scala 2.8.0
I have the AutoComplete widget running:
import _root_.net.liftweb.widgets.autocomplete._
...
bind(....
"foobar" -> Autocomplete(start, options, onSubmit),
...
The suggestions from "options" pop up when I type into the text field.
Question 1:
How do I clear the field in a way that the onSubmit function does not
return the latest value selected from the drop down list?
When I first select a value from the drop down list, I can use the
delete key or a space bar to empty the input field. However, the
onSubmit function still returns the value from the drop down list.
Perhaps one of the jsonOptions? The only one that caught my eye
"mustMatch" is already set to "false" be default...
Question 2:
Ajax elements usually call a Lift function (to emit a JsCmd) when a
change occurs. Is there something similar for the AutoComplete widget?
Thanks
Michael
--
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.
Am 01.03.2011 15:02, schrieb Sergey Andreev:
> Hi Michael,
>
> Question 1:
>
> You need to modify the AutoComplete widget's source code and add
> handlers for onBlur/keypress events so that they will change the value
> of the hidden field appropriately.
Thanks.
I have no idea how to do that. But that hasn't stopped me before, so I
had a look at the source code.
I found the place where the JQuery calls and the input fields are
generated.
I presume that an onBlur event handler can be inserted in a similar way
as shown in SHtml.scala with the areaText_* function.
But I am at a loss on how to change the hidden field value. I'm not
familiar with the inner workings of JavaScript.
I can confirm that behaviour in also present in Lift 2.2.
I think one might call it a bug, because it is also responsible for the
following "unexpected" behaviour of the widget:
If you enter text in the autocomplete text field without ever touching
the drop down list, the entered value is NOT returned to the
application. It does not matter if the entered value is part of the drop
down list or not.
It seems that the hidden field is ONLY updated if a list entry is
selected. Any manual entries into the text field are ignored.
>
> Question 2:
>
> Yes, AutoComplete uses JQuery AutoComplete plugin which makes ajax
> calls to the server.
Sorry, I rephrase.
I'm aware that the AutoComplete plugin uses ajax calls to populate the
drop down list. I was wondering if an event is fired when a selection
had occurred (but before the form is submitted).
A use case could be: The user selects an article from the drop down list
and additional information is displayed (using DisplayMessage or
similar) before the form is submitted.
Kind regards
Michael
>
>
> On Mon, Feb 28, 2011 at 12:38 PM, Michael Strecke
> <michael...@googlemail.com
> <mailto:lif...@googlegroups.com>.
> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com
> <mailto:liftweb%2Bunsu...@googlegroups.com>.
thank you for the info. I managed to modify the AutoComplete class to
implement your solution (the "onLoad2" parts below).
I'm not sure, if onLoad and onLoad2 can be merged somehow, but it does
work this way.
Even though the AutoComplete is not a top priority, I will open a
ticket. Perhaps the powers that be will pick it up if the solution is
presented on a silver platter.
Thank you for your help
Michael
val onLoad = JsRaw("""
jQuery(document).ready(function(){
var data = """+what.encJs+""";
jQuery("#"""+id+"""").autocomplete(data,
"""+autocompleteOptions.toJsCmd+""").result(function(event, dt, formatted) {
jQuery("#"""+hidden+"""").val(formatted);
});
});""")
val onLoad2 = JsRaw("""
jQuery(document).ready(function(){
jQuery("#"""+id+"""").bind("blur", function() {
jQuery("#"""+hidden+"""").val(jQuery("#"""+id+"""").val());
});
});""")
<span>
<head>
<link rel="stylesheet" href={"/" +
LiftRules.resourceServerPath +"/autocomplete/jquery.autocomplete.css"}
type="text/css" />
<script type="text/javascript" src={"/" +
LiftRules.resourceServerPath +"/autocomplete/jquery.autocomplete.js"} />
{Script(onLoad)}
{Script(onLoad2)}
</head>
Am 02.03.2011 11:30, schrieb Sergey Andreev:
> Hi Michael,
>
> As far as i understand the AutoComplete widget is not a top priority
> right now so all you can do is to hack around the existing widget.
>
> You can use something like that for blur (onkeypress) events to update
> hidden field:
>
> jQuery(#textFieldId).bind("blur", function() {
> jQuery(#hiddenFieldId).val(jQuery(#textFieldId).val());
> });
>
> jQuery AutoComplete fires events when you type the text. This events
> are handled using options function on the AutoComplete widget.
> Unfortunately the server call should return a list of strings so i am
> not sure if you can display additional information.
>
> Best regards,
> Sergey
>
> On Wed, Mar 2, 2011 at 11:10 AM, Michael Strecke
> <michael...@googlemail.com
> > <mailto:michael...@googlemail.com
> > <mailto:lif...@googlegroups.com
> <mailto:lif...@googlegroups.com>>.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com
> <mailto:liftweb%2Bunsu...@googlegroups.com>
> > <mailto:liftweb%2Bunsu...@googlegroups.com
> <mailto:liftweb%252Buns...@googlegroups.com>>.
I've attached a patch against 2.2-final - only 8 lines... if someone is
listening
Thanks again for your help Sergey.
Michael
Thanks again for your help Sergey.
Michael
--
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.
On Wed, Mar 2, 2011 at 5:03 PM, Michael Strecke <michael...@googlemail.com> wrote:
Am 03.03.2011 01:00, schrieb Michael Strecke:
> Even though the AutoComplete is not a top priority, I will open aWell, I'm not the only one with the problem. A ticket was already added
> ticket. Perhaps the powers that be will pick it up if the solution is
> presented on a silver platter.
>
a few days ago...
https://www.assembla.com/spaces/liftweb/tickets/892-autocomplete%28%29-should-have-option-to-allow-user-to-enter-their-own-value
I've attached a patch against 2.2-final - only 8 lines... if someone is
listening
This kind of statement is not welcome in the Lift community. Please see http://liftweb.net/community
Being polite will get you what you want a lot faster than not being polite.
Oops,
I'm sorry, if my wording is misleading.
It was not my intention to be rude.
I should have used more smilies or mark it with an <irony> tag.
Nevertheless - presenting a solution and creating a patch will speed up things, right? :-) ;-)
But as you (Michael, not David :-) may have seen there's a Lift
Modules initiative under way which should make it easier to contribute
something that is not in core Lift. I think a rewritten autocomplete
widget would fit this nicely....
Search the list or ask if you need more details....
/Jeppe
--
Andreas Joseph Krogh <and...@officenet.no>
Senior Software Developer / CTO
Public key: http://home.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Rosenholmveien 25 | know how to do a thing and to watch |
1414 Trollåsen | somebody else doing it wrong, without |
NORWAY | comment. |
Org.nr: NO 981 479 076 | |
| |
Tlf: +47 24 15 38 90 | |
Fax: +47 24 15 38 91 | |
Mobile: +47 909 56 963 | |
------------------------+---------------------------------------------+
--
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.
2011/3/3 David Pollak <feeder.of...@gmail.com>:
What does IP mean in this context?
I'm observing and reflecting upon what I observe. I think you've done a
fantastic job with both Lift and this community.
--
Andreas Joseph Krogh <and...@officenet.no>
Senior Software Developer / CTO
Public key: http://home.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Rosenholmveien 25 | know how to do a thing and to watch |
1414 Troll�sen | somebody else doing it wrong, without |