opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

A button with the ngDisabled directive is not disabled #43

Closed jupiterplanet closed 12 years ago

jupiterplanet commented 12 years ago

I am using AngularJS 1.0.0rc8, jQuery mobile 1.2.0 Pre and jQuery mobile Angular adapter 1.0.7-rc1.

I have used the following line of HTML-code:

<input type="button" ng-disabled="someexpression" value="Some title"></input>

However, the button is not disabled when someexpression is true.

I have tracked this down in the code. Here is an extract of the code which seems to not work correctly:

jqmng.define('jqmng/widgets/disabledHandling', ['jquery', 'angular'], function ($, angular) {
        var mod = angular.module('ng');

        function instrumentAttrSetter(element, attr) {
       // ...
            attr.$set = function (key, value) {
                var res = _$set.apply(this, arguments);
                if (key === 'disabled') {
                    var jqmOperation = 'enable';
                    if (value === 'disabled' || value == 'true') {
                        jqmOperation = 'disable';
                    }
      // ..

The jqmOperation is set to disabled if value is 'disabled' or 'true'. Unfortunately, the function is invoked with a boolean value true not a string value 'true'.

To test this assumption I have just added a value == true as in

 if (value === 'disabled' || value == 'true' || value == true) {

and now it works as intended. As I don't know how the frameworks actually work internally this is probably not the right way to fix it but it gives an idea of what is going wrong.

tbosch commented 12 years ago

Hi, thanks for reporting this. However, there is already the rc-2 version of the adapter out, and I changed a lot in it.

So, could you test the bug again with the rc-2 version of the adapter?

Tobias P.S.: By the way, I did not have time yet to verify the adapter against jqm 1.2pre, only against jqm 1.1.

jupiterplanet commented 12 years ago

First of all thanks for your fast reply and all the hard work you have put into this great piece of software. You are definitely right, I have tried it with your latest release candidate (rc2) and the disabling of buttons work. However, while migrating to rc2 I have encountered some issues I have described in

For each issue I have also provided a jsFiddle Thanks again for your help. I have build all jsFiddles with jqm 1.1 and AngularJS 1.0.0rc9 which I have found was your latest version you have updated to.

tbosch commented 12 years ago

Hi, with the current snapshot version (1.0.7-rc3-SNAPSHOT) this is working as intended: http://jsfiddle.net/ARprU/1/

I will look at the other issues shortly.

Tobias