Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // append footer at the end of dropdown list
- $('#select-id').select2('container').append('<hr style="margin:5px"><a href="javascript:void(0)" onclick="add_new_option()"><img src="images/plus.png"/> Add New</a>');
- // trigger on click
- function add_new_option() {
- $('#select-id').select2('container').select2('close');
- var new_option_val, new_option_name;
- /*
- display form/dialog box and add to db
- */
- $('#select-id').append('<option value='+new_option_val+'>'+new_option_name+'</option>');
- $('#select-id').select2('val', new_option_val);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement