nobleclem/jQuery-MultiSelect

destroy method

Closed this issue · 6 comments

I'm always frustrated when i need to destroy the element manually removing all content

i you'd like to know is possible to create a destroy method to do that automatically.

I don't fully understand what you are needing? There is an unload method that will turn the plugin off and show the native <select> element.

@rajatpatra12 So the issue I see is that even though you can create an element with the same id multiple times the html spec says you shouldn't do that and ID's should be unique (https://www.w3schools.com/Tags/att_global_id.asp). So the plugin is triggering 3 times because you have 3 elements that match the same selector.

Not having code its hard to say what you are doing. But this is a test to verify that unloading method works. This initializes the dropdown, then 5 seconds later unloads the plugin, and after another 5 seconds reloads the plugin. Then when I select a new option I only see the value of that option outputting to console once per click not twice.

var selectListPluginOptions = {
    columns: 4,
    texts: {
        placeholder: 'Select options'
    },
    onOptionClick: function( element, option ) {
        console.log( $(option).val() );
    }
};

var list = $('select[multiple]').multiselect( selectListPluginOptions );

setTimeout( function(){
    console.log( 'unloading plugin' );
    list.multiselect( 'unload' );
}, 5000 );

setTimeout( function(){
    console.log( 'reloading plugin' );
    list = $('select[multiple]').multiselect( selectListPluginOptions );
}, 10000 );

thanks in advance patric

I am not sure how to help you. You provided me with a vague description of the problem you are having with no supporting code. Then you just paste the code I provided eliminating one of the setTimeout calls. Again this doesn't tell me anything. Unless you can provide enough code for me to replicate the issue I cannot help you. You might just need to find a friend that you can debug the issue with in person.

Please stop treating this thread like a text message. Compose your response and send it once instead of sending multiple messages.

If all you are doing is needing to change the options in the list that is easy and doesn't require loading and unloading the plugin. What you are looking for there is the loadOptions method. There is an example in the README.md file as well as an example working demo on the demo page should be the 4th example.

I think you just need to spend some time looking through the examples as well as the documentation in the README.md file. I simply do not have the time to do everyones work for them. At this point there is a bug in this plugin that has been identified.