diff options
Diffstat (limited to 'src/widgets.js')
| -rw-r--r-- | src/widgets.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/widgets.js b/src/widgets.js index fbca8436..24eba900 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -340,3 +340,25 @@ var ngSwitch = angularWidget('ng:switch', function (element){ }, route: switchRouteMatcher }); + + +/* + * Modifies the default behavior of html A tag, so that the default action is prevented when href + * attribute is empty. + * + * The reasoning for this change is to allow easy creation of action links with ng:click without + * changing the location or causing page reloads, e.g.: + * <a href="" ng:click="model.$save()">Save</a> + */ +angular.widget('a', function() { + this.descend(true); + this.directives(true); + + return function(element) { + if (element.attr('href') === '') { + element.bind('click', function(event){ + event.preventDefault(); + }); + } + }; +});
\ No newline at end of file |
