Author: david
Date: Tue Dec 8 17:28:00 2009
New Revision: 4124
Log:
Add clearDialog() function.
Modified:
trunk/web/js/dialog.js
Modified: trunk/web/js/dialog.js
==============================================================================
--- trunk/web/js/dialog.js Tue Dec 8 17:00:43 2009 (r4123)
+++ trunk/web/js/dialog.js Tue Dec 8 17:28:00 2009 (r4124)
@@ -13,6 +13,32 @@
return dataObject;
}
+function clearDialog(dialog, dialogData)
+{
+ // Remove "id" input
+ $(dialog).find('input[name="id"]').remove();
+
+ // Clear input fields
+ for (name in dialogData.fields)
+ {
+ switch (dialogData.fields[name].type)
+ {
+ case 'text':
+ $(dialog).find('input[name="' + name + '"]').val('');
+ break;
+ case 'textarea':
+ $(dialog).find('textarea[name="' + name + '"]').val('');
+ break;
+ case 'select-one':
+ // Select first option in single option select controls
+ $(dialog).find('select[name="' + name +
'"]').get(0).options[0].selected = true;
+ break;
+ }
+ }
+
+ return true;
+}
+
function appendHiddenFields(thisForm, options)
{
// Build hidden form input fields
@@ -84,7 +110,7 @@
'</div>' +
'</div>');
- // Replace table with "add" link and move into dialog wrapper
+ // Replace dialog table with "add" link and move into dialog wrapper
$(table)
.removeClass('dialog')
.replaceWith('<a href="javascript:yuiDialog.show();">Add</a>')
@@ -126,12 +152,12 @@
var handleSubmit = function() {
submitDialog(this.getData(), new DialogObject, counter++); // Save
the data to the main form
this.hide(); // Hide dialog
- //clearActorEventDialog(); // Clear the dialog form
+ clearDialog(table, new DialogObject); // Clear dialog values
};
var handleCancel = function() {
this.cancel();
- //clearActorEventDialog();
+ clearDialog(table, new DialogObject);
};
yuiDialog = new YAHOO.widget.Dialog($(table).attr('id'),
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.