Created
January 13, 2013 19:53
-
-
Save vsergeyev/4525888 to your computer and use it in GitHub Desktop.
Sample popup form with bootbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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