Opened 7 years ago

Closed 7 years ago

#16133 closed defect (fixed)

dojox.mobile.ListItem set clickable after xhr request

Reported by: johnsonr Owned by: Eric Durocher
Priority: undecided Milestone: 1.9
Component: DojoX Mobile Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:

Description

Trying to set the property 'clickable' of a dojox.mobile.ListItem? to false after receiving the response of a XHR request is failing. See line 15 where it works just fine. But line 32 fails. This line is part of the XHR callback. The ListItem? is passed to the callback using the xhrArgs object (line 21).

It is not possible to set a property of a widget after it has been created.

define([
    "dojo/_base/declare", 
    "dojox/mobile/ListItem",
    'dojo/request/script',
    ], function(declare, ListItem, Request {
        return declare([ListItem], {
            constructor: function() {
                this.clickable  = true;
            },
            
            postCreate: function() {
                this.isClickable();
                
                // This works !!
                this.set('clickable', false);
            },
            
            isClickable: function() {
                var xhrArgs = {
                    jsonp: 'callback',
                    listItem: this,
                };
                    
                Request.get(myUrl, xhrArgs).then(function(data) {
                    if (undefined === data) {
                        // This ListItem must be disabled and not clickable.
                    
                        // Works
                        xhrArgs.listItem.set('class', 'disabled');
                        
                        // Don't work!! The ListItem is still clickable.
                        xhrArgs.listItem.set('clickable', false);
                        
                        // The ListItem where the property 'clickable' is false
                        console.log(xhrArgs.listItem);
                    } else {
                        // This ListItem is clickable.
                        xhrArgs.listItem.set('clickable', true);
                    }
                });
            },
            
            onClick: function(e) {
                // Do things...
            },
        });
    }
);

Attachments (1)

patch16133.patch (12.9 KB) - added by Adrian Vasiliu 7 years ago.
Fix the handling of changes of ListItem's "clickable", "moveTo", "href", and "url" properties when the setter is called after startup. Includes a new DOH test. - Adrian Vasiliu, IBM, CCLA

Download all attachments as: .zip

Change History (6)

comment:1 Changed 7 years ago by Eric Durocher

Correct, "clickable" can only be set at creation time (more exactly before startup() is called). This will be either fixed, or documented.

As a workaround you can set "preventTouch" to true, this will disable the ListItem.

comment:2 Changed 7 years ago by Adrian Vasiliu

The same issue holds for changes after startup of the properties moveTo, href, and url.

The title of this ticket could be changed into:

dojox/mobile: ListItem should properly support changes of its properties "clickable", "moveTo", "href", and "url" even after widget's startup

The attached patch16133.patch contains:

  • a DOH test to reproduce the issue for each of these properties.
  • a fix proposal; however we need to decide if this is the way we want to go, knowing that there are many other cases when changing properties after startup is too late, and going the same way for all might be overkill.
Last edited 7 years ago by Adrian Vasiliu (previous) (diff)

comment:3 Changed 7 years ago by Adrian Vasiliu

(Updated the patch to resync it with current trunk and other few minor changes in tests.)

comment:4 Changed 7 years ago by cjolif

Milestone: tbd1.9

Changed 7 years ago by Adrian Vasiliu

Attachment: patch16133.patch added

Fix the handling of changes of ListItem's "clickable", "moveTo", "href", and "url" properties when the setter is called after startup. Includes a new DOH test. - Adrian Vasiliu, IBM, CCLA

comment:5 Changed 7 years ago by cjolif

Resolution: fixed
Status: newclosed

In [30723]:

fixes #16133. Fix the handling of changes of ListItem?'s clickable, moveTo... properties when the setter is called after startup. Includes a new DOH test. Thanks Adrian Vasiliu (IBM, CCLA). !strict

Note: See TracTickets for help on using tickets.