HTML5 use for filter

HTML5 use for filter

mjdinsmoremjdinsmore Posts: 10Questions: 1Answers: 0
edited March 2013 in Bug reports
I am classifying this as a bug because it was something noticed/commented upon in the DataTables 1.8 release as being trivial (and it is) but it's still not fixed. It would be nice to have the HTML input type to be "search" instead of "text" for the filter. This would allow it to automatically have a clear button on supporting browsers. There was a comment from Allan saying how it'd be trivial to make the change with jQuery (see http://datatables.net/forums/discussion/5178/little-suggestion-use-html5-input-typesearch-for-the-search-textbox/p1). The only problem is that his recommendation does not work with jQuery. If you look at the jQuery code, you'll see:

[code]

// We can't allow the type property to be changed (since it causes problems in IE)
if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
throw "type property can't be changed";
[/code]

This will prevent you from trying to dynamically changing the attribute type - e.g. $('#filter_input').attr('type', 'search'); . This will just give you the error "type property cannot be changed".

It would be nice to have this fixed. As bonus points, since you're in that area of code, why not also add a "placeholder" HTML5 element as well, and allow that text to be easily configurable by the user, but maybe default it with something like "Enter your text to filter" or something like that.

Replies

  • allanallan Posts: 63,685Questions: 1Answers: 10,498 Site admin
    Already in git: https://github.com/DataTables/DataTables/commit/8d9e620ef2c4e3a1d566ea65728c0f1d69eafabe :-)

    Will be available in 1.10.

    Allan
  • mjdinsmoremjdinsmore Posts: 10Questions: 1Answers: 0
    Awesome. Thanks!
This discussion has been closed.