Opened 8 years ago
Closed 8 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)
Change History (6)
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
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.
comment:3 Changed 8 years ago by
(Updated the patch to resync it with current trunk and other few minor changes in tests.)
comment:4 Changed 8 years ago by
Milestone: | tbd → 1.9 |
---|
Changed 8 years ago by
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
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.