How to use Checkbox inside Select Option

前端 未结 12 2250
夕颜
夕颜 2020-11-22 09:15

The client has given me a design which has a Select Option menu containing a checkbox together with the item name as individual items in the list. Is there anyway possible t

12条回答
  •  温柔的废话
    2020-11-22 09:51

    You might be loading multiselect.js file before the option list updated with AJAX call so while execution of multiselect.js file there is empty option list is there to apply multiselect functionlaity. So first update the option list by AJAX call then initiate the multiselect call you will get the dropdown list with the dynamic option list.

    Hope this will help you out.

    Multiselect dropdown list and related js & css files

    // This function should be called while loading page
    var loadParentTaskList = function(){
        $.ajax({
            url: yoururl,
            method: 'POST',
            success: function(data){
                // To add options list coming from AJAX call multiselect
                for (var field in data) {
                    $('').appendTo('#parent_task');
                }
       
                // To initiate the multiselect call 
                $("#parent_task").multiselect({
                    includeSelectAllOption: true
                })
            }
        });
    }
    // Multiselect drop down list with id parent_task
    

提交回复
热议问题