Skip to content

Instantly share code, notes, and snippets.

@vsergeyev
Created January 13, 2013 19:53
Show Gist options
  • Save vsergeyev/4525888 to your computer and use it in GitHub Desktop.
Save vsergeyev/4525888 to your computer and use it in GitHub Desktop.
Sample popup form with bootbox
var form = $("<form></form>");
form.append("<label>Title:</label> <input type=text name='title' />");
form.append("<label>Description:</label> <textarea name='description'></textarea>");
bootbox.form("Project settings", form, function($form) {
if (!$form) return;
var settings = {};
$form.find(':input[name]:enabled').each( function() {
var self = $(this);
var name = self.attr('name');
if (settings[name]) {
settings[name] = settings[name] + ',' + self.val();
} else {
settings[name] = self.val();
}
});
$.post("/project_settings/", settings, function (v) {
console.log("Settings saved");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment