Coder Social home page Coder Social logo

How to reuse ? about multi.js HOT 4 CLOSED

chenyb888 avatar chenyb888 commented on June 21, 2024
How to reuse ?

from multi.js.

Comments (4)

prototype-59 avatar prototype-59 commented on June 21, 2024 2

with jquery you can use:

$( '#mylist" ).val([]);
$( '#mylist" ).trigger( "change" );

great plugin. .refresh function would be nice.

from multi.js.

fabianlindfors avatar fabianlindfors commented on June 21, 2024

Hi!

Multi always matches the select element it was initialized on. I would suggest you clear out the selection between uses of the popup and then trigger a change event on the select element to update multi.

Here's an example:

// Init multi.js with select_element
multi( select_element, {
    'enable_search': true,
    'search_placeholder': 'Search...',
});

// Do something else...

// Clear select_element selection
for ( var i = 0; i < select_element.options; i++ ) {
    select_element.options[i].selected = false;
}

// Create and trigger change event on element (to make sure multi updates)
var e = document.createEvent( 'HTMLEvents' );
e.initEvent( 'change', false, true );
select_element.dispatchEvent( e );

from multi.js.

chenyb888 avatar chenyb888 commented on June 21, 2024

thanks. but it's too complex. why do not implement a method just like .refresh()?

from multi.js.

chenyb888 avatar chenyb888 commented on June 21, 2024

ok,thank you

from multi.js.

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.