I want to use jquery dialog to collect user information( user name for example). How do I do that with Jquery and collect data into Javascript variable?
This is my attempt so far:
// Dialog here, how to rewrite this?
$('<form> <input type="text" style="z-index:10000" name="name"> <br> </form>').dialog({modal:true});
// push data to Parse
var Label = Parse.Object.extend("Label");
var result = new Label();
result.set("labels", localStorage.getItem("labels"));
result.set("name", name);
result.save(null, {
sucess : function(result) {
alert("Stored data sucessfully!");
},
error: function(result, error) {
alert("Error submitting data, error code:" + error.message);
}
});
However I couldn't enter text yet.
You can put any functionality you want in the buttons section so when the user clicks ok, you process their info then. The docs for this are here. For instance:
$('<form><input type="text" style="z-index:10000" name="name"><br></form>').dialog({
modal: true,
buttons: {
'OK': function () {
var name = $('input[name="name"]').val();
storeData(name);
$(this).dialog('close');
},
'Cancel': function () {
$(this).dialog('close');
}
}
});
Here is a fiddle that shows this in action (albeit with no styling): http://jsfiddle.net/duffmaster33/zuervqop/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With