Trace:
Differences
This shows you the differences between two versions of the page.
totara:dialogs [2016/06/01 19:15] onno [Architecture of A Totara Dialog Box] |
totara:dialogs [2016/06/01 19:19] (current) onno [Saving] |
||
---|---|---|---|
Line 78: | Line 78: | ||
</code> | </code> | ||
+ | But ''/totara/plan/components/objective/find-course.js'' adds its own _save handler to a button which is passed along to totaraDialog during the initialization (line 103): | ||
+ | <code> | ||
+ | buttonsObj[M.util.get_string('save','totara_core')] = function() { handler._save(saveurl); } | ||
+ | </code> | ||
+ | |||
+ | In the end, the js file calls the php update script, e.g. ''/totara/plan/components/objective/update-course.php'', line 98 (see also the next part of this tutorial): | ||
+ | |||
+ | <code> | ||
+ | var saveurl = url + 'update-course.php?planid='+ // etc | ||
+ | </code> | ||
+ | |||
+ | ===== Updating The Page through Ajax ===== | ||
+ | In the case of the Linked Courses section on the Objectives tab (so, ''/totara/plan/components/objective/view.php?id=1&itemid=1''), the page is updated if you save a linked course. The javascript calls this php script to produce the updated output: | ||
+ | |||
+ | <code> | ||
+ | /totara/plan/components/objective/update-course.php | ||
+ | </code> | ||
+ | |||
+ | The javascript also contains an update handler, which is presumably a callback function (line 74 of ''/totara/plan/components/objective/find-course.js''): | ||
+ | |||
+ | <code> | ||
+ | totaraDialog_handler_preRequisite.prototype._update = function(response) { | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
+ | ===== Removing Items ===== | ||
+ | The items displayed in a dialog usually cannot be deleted (removed) there. Instead, on the main page you’ll see a submit button, e.g. “Remove linked courses”. This button submits to the main page itself, with a specific action, e.g. in | ||
+ | ''/totara/plan/components/objective/view.php'': | ||
+ | |||
+ | <code> | ||
+ | if ($action === 'removelinkedcourses' && !$plan->is_complete()) { | ||
+ | //... call removal code here | ||
+ | </code> | ||