Comments (6)
I think I've figured out how to check browser support. I've only tested this in Safari 5.1.1, Firefox 7.0.1, Chrome 15.0.874.121 and Opera 11.60 on my mac. So someone will need to see how this works in browsers on Windows.
var search = $('#search')[0];
if( search.list !== null || search.list !== undefined )
console.log('supported!'); // Firefox and Opera pass
from relevant-dropdowns.
what about safari?? coz safari has partial support
from relevant-dropdowns.
@ruanmer The code I included doesn't include Safari. Safari acts kind of weird because it finds the datalist
, but it doesn't create the drop down.
from relevant-dropdowns.
Yeah the majority of the suckness of testing for this is that Safari reports success but should not. Ideally we think of a fancy test we can perform (beyond just checking for the list attribute) that gives correct results in all browsers. I'm fairly stumped at the moment.
Ideally, that test would be baked into Modernizr.
from relevant-dropdowns.
Any updates? +1 for stand alone.
from relevant-dropdowns.
This will check for browser support then load the library w/o modernizr. Then
<script type="text/javascript">
(function () {
/**
* Loads a new javascript then performs a function
*/
function loadScript (url, then) {
var script = document.createElement('script');
script.addEventListener('load', then);
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', url);
document.head.appendChild(script);
}
if (!('options' in document.createElement('datalist'))) {
loadScript('/path/to/jquery.relevant-dropdown.js', function () {
$('input[list]').relevantDropdown();
});
}
})();
</script>
from relevant-dropdowns.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relevant-dropdowns.