Coder Social home page Coder Social logo

Comments (6)

BaylorRae avatar BaylorRae commented on September 26, 2024

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.

ruanmer avatar ruanmer commented on September 26, 2024

what about safari?? coz safari has partial support

from relevant-dropdowns.

BaylorRae avatar BaylorRae commented on September 26, 2024

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

chriscoyier avatar chriscoyier commented on September 26, 2024

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.

chrisabrams avatar chrisabrams commented on September 26, 2024

Any updates? +1 for stand alone.

from relevant-dropdowns.

AlgyTaylor avatar AlgyTaylor commented on September 26, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.