Dev.Opera - Follow the standards, break the rulesDev.Opera - Follow the standards, break the rules

Login

Lost password?

Forums » Article Discussions

Discuss the articles posted on Dev.Opera.

Note: You need to login to post in the forums. if you don't have an account you first need to sign up.

By anne O anchor Thursday, 11. October 2007, 15:03:08

An HTML5-style "Google Suggest"

This article is an exploration of some HTML5 form features - input, datalist and external data sources - along with some nifty server-side code to help create an intelligent auto-complete form field, a la Google Suggest, in very few lines of code.

( Read the article )

By lockoom anchor Friday, 12. October 2007, 06:50:48

avatarI do believe that it is possibly to copy Google Suggest with new HTML5 elements but your examples unfortunately can't compete with with original GS.
If you mention Google Suggest people will compare you examples with it. And what can I say, maybe GS need "few" :wink: lines of code more but it's far greater experience then HTML5-style.
And complexityis not that big issue as there are plenty of JS libraries with Google suggest-like functionality.
Don't understand me wrong, HTML5 is great thing but to succeed it must provide at least comparable experience to today's JS "hacks".

By anne O anchor Monday, 15. October 2007, 08:59:54

avatarThe point not really to duplicate the user interface, but more so how you can solve the problem in a more "semamntic way" using HTML5. Styling and such would be done on top of the widget.

By FataL anchor Monday, 3. December 2007, 07:26:37

avatarI just curious if input event should be fired in case of Paste, Cut or any other action that can change field?
I started digging this issue while developing a widget with word counter using OUTPUT element.

Update: Ok, I see some improvements here in Opera 9.5 Beta.
Opera 9.5 Beta 1 reacts on pasting and dragging (moving) selected symbols by mouse, but still not handle cut action. So, I think this is just a bug and it should be fixed.

I created small test page on this issue.

Post edited Monday, 3. December 2007, 09:08:09

By anne O anchor Monday, 10. December 2007, 11:54:55

avatarYeah, any kind of input has to trigger the event. Please file a bug on the cut issue.

By FataL anchor Monday, 10. December 2007, 17:45:48

avatarBug # 302395

By Akbalder anchor Tuesday, 18. August 2009, 07:28:15

avatarIn the HTML5 working draft ( http://www.w3.org/TR/html5/forms.html#the-datalist-element ), I can't find the data attribute of the datalist element.

Is it still in HTML5 ?

By anne O anchor Tuesday, 18. August 2009, 07:32:31

avatarNo, it was removed. We also removed it from Opera. You have to populate the datalist element now with new option elements. To load external data you would use XMLHttpRequest.

By Akbalder anchor Tuesday, 18. August 2009, 08:04:12

avatarIn latest Opera build, this code functions :
<datalist id="suggest" data="?w="></datalist>
<input list="suggest" name="q" oninput="list.data='?w='+encodeURIComponent(value)"></label>

I shouln't be able to use neither data="?w=" nor oninput="list.data='?w='+encodeURIComponent(value)" ?

By anne O anchor Tuesday, 18. August 2009, 08:07:57

avatarRight, I meant in post Opera 10 builds. Sorry about that.

By Akbalder anchor Tuesday, 18. August 2009, 08:15:35

avatarThanks,
I will change my code to be ready for the future. :wink:

By Akbalder anchor Wednesday, 19. August 2009, 07:18:33

avatarI modified the code to use xmlhttprequest but there is a problem :
When I add/remove options within the datalist element, the suggestions aren't updated directly.
They are only updated
- when I write another character in the input
- when the input looses and gains focus

When typing something in the input, the suggestions are always one character old.

Is it a known problem ? Is there any solution ?

By anne O anchor Wednesday, 19. August 2009, 07:21:50

avatarMaybe blur and then focus again? Also, please file a bug, I do not think that is known.

By Akbalder anchor Thursday, 20. August 2009, 07:13:18

avatarI filled a bug report.

Bluring and focusing the input works but it isn't smooth.
For now, I will just keep the suggestion being one character too old.

Moderators: pepelsbey | dstorey | mcx | operadev | chrismills | shwetankdixit | brucelawson | iheni | andreasbovens | zibin | mollydotcom