Skip to content

ui-sref not working with ng-click (angular-touch) if used without jQuery #827

Closed
@scheffield

Description

@scheffield

Hi,

I have a hard time removing jQuery from our app. The main problem: a simple link combining ng-click with ui-sref:

<a data-ui-sref="main2" data-ng-click="reportClick()">Link</a>

The result: ng-click fires, ui-sref does not.
This only happens when using angular-touch, without jQuery as a dependency and a mobile browser, or with the emulation of a mobile device in the new chrome 32 (I used an Nexus 4 as emulation target).

A running example: http://jsfiddle.net/scheffield/AEfMm/
To see the effect: http://jsfiddle.net/scheffield/AEfMm/show in a mobile browser

I already did a little research and found out that the event object is broken:

element.bind("click", function(e) {
        var button = e.which || e.button;

        if ((button === 0 || button == 1) && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
          // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
          $timeout(function() {
            scope.$apply(function() {
              $state.go(ref.state, params, { relative: base });
            });
          });
          e.preventDefault();
        }
      });

It is an object containing nothing but two functions implemented as angular.noop.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions