UI create form: Support custom checkbox 'on change' event If field is a checkbox (isBoolean: true) and onChange function is specified, then call this onChange everytime checkbox is clicked.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7e3b4408 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7e3b4408 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7e3b4408 Branch: refs/heads/javelin Commit: 7e3b4408cb2066f47537e486cd0a6e89bfa80826 Parents: b5d0072 Author: Brian Federle <[email protected]> Authored: Thu Aug 23 10:55:21 2012 -0700 Committer: Brian Federle <[email protected]> Committed: Thu Aug 23 11:08:12 2012 -0700 ---------------------------------------------------------------------- ui/scripts/ui/dialog.js | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7e3b4408/ui/scripts/ui/dialog.js ---------------------------------------------------------------------- diff --git a/ui/scripts/ui/dialog.js b/ui/scripts/ui/dialog.js index 86db690..88ffe57 100644 --- a/ui/scripts/ui/dialog.js +++ b/ui/scripts/ui/dialog.js @@ -273,6 +273,15 @@ }, 100); } } + + // Setup on click event + if (field.onChange) { + $input.click(function() { + field.onChange({ + $checkbox: $input + }); + }); + } } else if (field.dynamic) { // Generate a 'sub-create-form' -- append resulting fields $input = $('<div>').addClass('dynamic-input').appendTo($value);
