Permalink
Browse files

Fixing event stopping in mootools

  • Loading branch information...
markstory committed Mar 16, 2009
1 parent eea1fa5 commit e237eec3431a91aaff9eea324f4fdef549cc4a95
@@ -80,7 +80,7 @@ function event($type, $callback, $options = array()) {
$function = 'function (event) {%s}';
if ($options['wrap'] && $options['stop']) {
- $callback .= "\nreturn false;";
+ $callback = "event.stop();\n" . $callback;
}
if ($options['wrap']) {
$callback = sprintf($function, $callback);
@@ -157,7 +157,19 @@ function effect($name, $options = array()) {
* @return string The completed ajax call.
**/
function request($url, $options = array()) {
+ $result = $this->Moo->request(array('controller' => 'posts', 'action' => 'view', 1));
+ $expected = '$.ajax({url:"/posts/view/1"});';
+ $this->assertEqual($result, $expected);
+ $result = $this->Moo->request('/people/edit/1', array(
+ 'method' => 'post',
+ 'complete' => 'doSuccess',
+ 'error' => 'handleError',
+ 'type' => 'json',
+ 'data' => array('name' => 'jim', 'height' => '185cm')
+ ));
+ $expected = '$.ajax({method:"post", error:handleError, data:"name=jim&height=185cm", dataType:"json", success:doSuccess, url:"/people/edit/1"});';
+ $this->assertEqual($result, $expected);
}
}
?>
@@ -85,7 +85,7 @@ function testEvent() {
$this->assertEqual($result, $expected);
$result = $this->Moo->get('#myLink')->event('click', 'this.setStyle("display", "none");');
- $expected = "\$(\"myLink\").addEvent(\"click\", function (event) {this.setStyle(\"display\", \"none\");\nreturn false;});";
+ $expected = "\$(\"myLink\").addEvent(\"click\", function (event) {event.stop();\nthis.setStyle(\"display\", \"none\");});";
$this->assertEqual($result, $expected);
}
/**

0 comments on commit e237eec

Please sign in to comment.