Code Monkey home page Code Monkey logo

Comments (4)

adamcoulombe avatar adamcoulombe commented on August 16, 2024

There are two ways to do it. The best way is to append your options then run customSelect:
http://jsfiddle.net/adamco/rvgZ3/

But sometimes you need to add options to a select that already has customSelect. In that case, you append your options, then trigger an update:

http://jsfiddle.net/adamco/v7Uzz/

from jquery.customselect.

Mathiu avatar Mathiu commented on August 16, 2024

Yeah, i know that, and i actually done it in one case, but in another one when i am not able to find function responsible for filling my select i can't use any of those methods, because first one is emptying my select because of trigger update and i can't use second one.

P.S. I have this problem in magento commerce and i really don't want to change any core js files which are filling my selects.

from jquery.customselect.

adamcoulombe avatar adamcoulombe commented on August 16, 2024

Not really familiar with magento. Ideally you would want to trigger the update inside a callback or event handler, so you could check the magento docs for that. Otherwise, you said it is working, but the only other suggestion I might say is you could poll to check when the content of the select changes.

<select id="myselect"></select>

js

var $select = $('#myselect');
function checkIfSelectHasBeenPopulated(){
    if($select.html().length<1){
        setTimeout(checkIfSelectHasBeenPopulated,300);
    }else{
        $select.trigger('update');
    }
}
checkIfSelectHasBeenPopulated();

from jquery.customselect.

Mathiu avatar Mathiu commented on August 16, 2024

Me neither. And that's why i'am struggling with it. I will stay with my little fix.

Many thanks for your time and a great script :)

from jquery.customselect.

Related Issues (20)

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.