Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // append footer at the end of dropdown list
  2. $('#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>');
  3.  
  4. // trigger on click
  5. function add_new_option() {
  6. $('#select-id').select2('container').select2('close');
  7.  
  8. var new_option_val, new_option_name;
  9. /*
  10. display form/dialog box and add to db
  11. */
  12.  
  13. $('#select-id').append('<option value='+new_option_val+'>'+new_option_name+'</option>');
  14. $('#select-id').select2('val', new_option_val);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement