<md-button> ng-click fires inconsistently with Ionic Framework/ng-Material latest versions
http://codepen.io/anon/pen/MYOeap
The plunker above works fine, I found this on the Ionic Framework forums and it's functional and the click is fired as expected.
However the same code with the latest ionic css/js files along with latest Angular Material via bower install, the click doesn't work as intended. Any reason? I've also installed the #master but the clicks on md-button still don't work very well. It may fire once every 10-20 clicks, and sometimes it fires once every 5 clicks. This is a hangup for me right now on moving forward with a project.
@bradmartin for us it was a trivial issue, we were including the libraries by using //cdn/ url refferals, once we used web normalized 'http://cdn" addressing it was all ok. Are you using a call to a modal for the login, or a controller? It may not be directly related to material, or just expected behavior.
The current master has improved the use of
<section layout="row" layout-align="center center">
<md-button nav-clear flex ng-click="Login()" class="md-raised md-primary">Login</md-button>
</section>
<br />
<br />
<br />
<p flex layout="row" layout-align="center center">
Don't have an account?
</p>
<section layout="row" layout-align="center center">
<md-button class="primary" flex md-no-ink href="#/register">Sign Up</md-button>
</section>
<br />
<br />
<br />
<div layout="row" layout-align="center center">
<md-button flex md-no-ink href="#/forgotpassword">Forgot password?</md-button>
</div>
In the markup above, the LOGIN button is working fine, just not the
any more information on this?
If you search through the issues you will see a few other related issues to gestures and events. I think they are all planned for the 0.9.0 release.
Just tried out the master version : v0.8.3-master-1cd1d69
In the snippet below the Login
<ion-view title="" hide-nav-bar="true">
<ion-content>
<form name="loginform" layout="row" layout-sm="column" novalidate>
<md-input-container flex>
<label>Username or Email</label>
<input ng-model="user.username" type="text">
</md-input-container>
<md-input-container flex>
<label>Password</label>
<input ng-model="user.password" type="password">
</md-input-container>
</form>
<section layout="row" layout-align="center center">
<md-button nav-clear flex ng-click="Login()" class="md-raised md-primary">Login</md-button>
</section>
<p flex layout="row" layout-align="center center">
Don't have an account?
</p>
<section layout="row" layout-align="center center">
<md-button class="primary" flex md-no-ink href="#/register">Sign Up</md-button>
</section>
<div layout="row" layout-align="center center">
<md-button flex md-no-ink href="#/forgotpassword">Forgot password?</md-button>
</div>
</md-content>
</ion-content>
</ion-view>
For Ionic-Angular Material mobile solutions that using jQuery, you can now disable Material click hijacking by using $mdGestureProvider in
app = angular.module('MyApp', ['ngMaterial'])
.config(function( $mdGestureProvider ) {
$mdGestureProvider.skipClickHijack();
});
This will configure the $mdGesture service to not intercept clicks (stop propagation and prevent defaults).
Works perfectly for my case. Thanks!
I tried using this and my Ionic Cordova App fails because Angular is throwing me an error:
Uncaught ReferenceError: jQuery is not defined
I had to do some code changes to make it work without an error.
Before:
var self = {
handler: addHandler,
register: register,
// On mobile w/out jQuery, we normally intercept clicks. Should we skip that?
isHijackingClicks: (isIos || isAndroid) && !JQuery && !forceSkipClickHijack
};
After:
var hasJQuery = typeof jQuery !== 'undefined' && angular.element === jQuery;
var self = {
handler: addHandler,
register: register,
// On mobile w/out jQuery, we normally intercept clicks. Should we skip that?
isHijackingClicks: (isIos || isAndroid) && !hasJQuery && !forceSkipClickHijack
};
@sebmaniac - great catch. This should be improved with the commit SHA https://github.com/angular/material/commit/a22f6817fb6e89f7004d91bc8ba895b860ea8578
thank you @ThomasBurleson,
$mdGestureProvider.skipClickHijack(); trick works perfectly for me
@ThomasBurleson FYI, this is happening again to Material v1.0.0 onwards.
However, the solution
$mdGestureProvider.skipClickHijack();
works nicely.
@ThomasBurleson thanks for your solution. it Works perfectly. Great
" $mdGestureProvider.skipClickHijack(); " Where to write it? @ThomasBurleson ,
@ilkayhan first import angular-material to get $mdGestureProvider, then do it in app.config.
Could there be a similar issue with the blur event firing when it is not necessary ? (Using along ionic-v1)
@ilkayhan - try
myAppModule.config(function($mdGestureProvider) {
$mdGestureProvider.skipClickHijack();
});
@jonathan68 you are using AngularJS Material with Ionic 2 or Angular Material with Ionic 2? For Angular Material, you can ask questions in their forums.
@ThomasBurleson can you say more about where
myAppModule.config(function($mdGestureProvider) {
$mdGestureProvider.skipClickHijack();
});
goes? I tried it in my main.js file but that didn't seem to work, do I need to import angular-material like @thomcom said?
@sas1018 what exactly happened when you say "didn't seem to work"? The relevant docs can be found here: https://material.angularjs.org/latest/api/service/$mdGestureProvider