An HTML5-style "Google Suggest"

Forums » Dev.Opera » Archived Article Discussions

This topic has been closed. No new entries allowed.

Reason: You can now post comments on articles on Dev Opera

Forum rules and guidelines

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

11. October 2007, 15:03:08

Opera Software

anne

CSS1Compat

Posts: 163

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 )

12. October 2007, 06:50:48

lockoom

Posts: 836

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

15. October 2007, 08:59:54

Opera Software

anne

CSS1Compat

Posts: 163

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

3. December 2007, 09:08:09 (edited)

FataL

Opera freak

Posts: 1443

I 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.
Main browser and mail: 9.27 • Secondary: 10.63 (still has annoying UI regressions: inability to detach tab normally, passes source file w/o extension to external editors)
extendopera.orgReport bugs to public BTS

10. December 2007, 11:54:55

Opera Software

anne

CSS1Compat

Posts: 163

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

10. December 2007, 17:45:48

FataL

Opera freak

Posts: 1443

Bug # 302395
Main browser and mail: 9.27 • Secondary: 10.63 (still has annoying UI regressions: inability to detach tab normally, passes source file w/o extension to external editors)
extendopera.orgReport bugs to public BTS

18. August 2009, 07:28:15

Akbalder

Posts: 59

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

18. August 2009, 07:32:31

Opera Software

anne

CSS1Compat

Posts: 163

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

18. August 2009, 08:04:12

Akbalder

Posts: 59

In 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)" ?

18. August 2009, 08:07:57

Opera Software

anne

CSS1Compat

Posts: 163

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

18. August 2009, 08:15:35

Akbalder

Posts: 59

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

19. August 2009, 07:18:33

Akbalder

Posts: 59

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

19. August 2009, 07:21:50

Opera Software

anne

CSS1Compat

Posts: 163

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

20. August 2009, 07:13:18

Akbalder

Posts: 59

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

14. January 2010, 10:48:52

Muzzlehatch

Posts: 20

Nice to see Opera so far ahead of the competition on this, although what we really need is everyone to support these useful controls as soon as possible. It's a real pity that the data attribute was dropped as it seems logical and much easier to work with. What was the reason for it being dropped?

30. January 2010, 15:17:09

Opera Software

anne

CSS1Compat

Posts: 163

It was dropped because the new form features took a long time to get adopted and we thought we should remove some of the complexity therefore. You can still implement this functionality yourself by dynamically populating the datalist element based on user input. Once all user agents have a reasonable implementation of the new HTML form functionality it might get added again though maybe in a different form.

9. February 2010, 21:07:13

Muzzlehatch

Posts: 20

Originally posted by anne:

It was dropped because the new form features took a long time to get adopted and we thought we should remove some of the complexity therefore. You can still implement this functionality yourself by dynamically populating the datalist element based on user input.


Given the terrible take up of the new elements I can sympathise with the pragmatic approach. There was good article in C'T Magazin (25/2009) which covered the new form elements and I wrote a test page. Apart from Opera pretty much all the new browsers failed across the board, although I do like Chrome's meter widget. Regarding the calendar widget - could we get two months instead of one as often as not dates will be crossing month boundaries. But regarding the data issue: AJAX sucks and the proposed solution was SO much more elegant.

17. May 2010, 08:47:50

Muzzlehatch

Posts: 20

Is there an easy way to check for HTML 5 form support in browsers? From the controversy around <video> you could be forgiven for thinking that HTML5 was only about the video tag! I'd like to have full HTML5 support for the repoze.defom form generation library but how do you approach <input type="date"> for browsers with built-in support such as Opera and JS calendar widgets for the rest? Also is there a test framework available apart from Selenium?

25. June 2011, 20:04:00

stofke72

Posts: 20

Originally posted by anne:

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 )



Guys example 2 and 3 http://html5.org/demos/dev.opera.com/article-examples.html

are simply not working in opera 10+.

27. June 2011, 02:43:10

donroberts

Posts: 2

I'm in agreement with stofke72's observation.
Don Roberts

Forums » Dev.Opera » Archived Article Discussions