Merged [47055]: Modified FormResponse to append Behaviour rules last.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60479 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Hayden Smith 2008-08-12 04:04:58 +00:00
parent b744a560f6
commit 6a6d0f1b35

View File

@ -31,6 +31,13 @@ class FormResponse {
* @var $rules array
*/
static protected $rules = array();
/**
* @var $behaviour_apply_rules array Separated from $rules because
* we need to apply all behaviour at the very end of the evaluated script
* to make sure we include all possible Behaviour.register()-calls.
*/
static protected $behaviour_apply_rules = array();
/**
* @var $non_ajax_content string
@ -227,9 +234,9 @@ class FormResponse {
}
if($reapplyBehaviour) {
if(isset($uniquenessID)) {
self::$rules[$uniquenessID] .= "Behaviour.apply('{$JS_domID}', true);";
self::$behaviour_apply_rules[$uniquenessID] .= "Behaviour.apply('{$JS_domID}', true);";
} else {
self::$rules[] .= "Behaviour.apply('{$JS_domID}', true);";
self::$behaviour_apply_rules[] = "Behaviour.apply('{$JS_domID}', true);";
}
}
}
@ -249,9 +256,13 @@ class FormResponse {
}
}
if(!empty($msg)) self::$rules[] = $msg;
$js .= implode("\n", self::$rules);
$js .= Requirements::get_custom_scripts();
// make sure behaviour is applied AFTER all registers are collected
$js .= implode("\n", self::$behaviour_apply_rules);
return $js;
}