Skip to content

Instantly share code, notes, and snippets.

@natsu90
Created January 2, 2014 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natsu90/8215771 to your computer and use it in GitHub Desktop.
Save natsu90/8215771 to your computer and use it in GitHub Desktop.
function add_new_option() {
$('#calendarbyuser').select2('container').select2('close');
// add random value
var today = new Date();
var new_option_val = today.getTime();
var new_option_name = prompt("Please enter your option","New Option "+today.getSeconds());
if(new_option_name != null)
{
$('#calendarbyuser').append('<option value='+new_option_val+'>'+new_option_name+'</option>');
$('#calendarbyuser').select2('val', new_option_val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment