Opened 14 years ago
Closed 6 years ago
#3905 closed defect (fixed)
Patch dojo.parser, OR stop putting widget code in event callbacks such as onShow, onRezised etc
Reported by: | mumme | Owned by: | bill |
---|---|---|---|
Priority: | low | Milestone: | 2.0 |
Component: | Dijit | Version: | 0.9 |
Keywords: | parser, markup, dijit events | Cc: | |
Blocked By: | Blocking: |
Description (last modified by )
Connecting to onShow in markup using TitlePane?, StackContainer? TabContainer? etc breaks href load.
This is just a symptom of a bigger problem. Say a designer wants to know when a TitlePane? shows
<div dojoType='dijit.TitlePane' href='somepage' open='false' title='Foo' onShow='console.debug("opened")' ></div>
When dojo.parser parses this markup it replaces TitlePane?'s onShow function, which currently triggers the href download, with:
function(){console.debug("opened")}
So we either patch the parser to connect instead of replace OR stop using public functions in widget to widget calls (not sure that is possible in all cases).
I suspect it has been discussed extensively already, still code like this is still being added to dijit trunk. I searched trac but couldn't find any tickets filed about this yet. So I figured I open a ticket to make people aware of this.
/ Fredrik
Change History (13)
comment:1 Changed 14 years ago by
Owner: | changed from bill to mumme |
---|
comment:2 Changed 14 years ago by
Owner: | changed from mumme to bill |
---|
Ok thanks for clearing that out, I suppose it's a question of what people use most, functions as events, or functions as mutators.
Yes I can for this particular case, it's the reason I only had _loadCheck in the first place in ContentPane?.
But I wont do Menu.js: onCancel, onItemHover, onItemUnHover, onItemClick, onOpen, onClose
nor Button.js onClick(2 places)
nor ValidationTextbox?.js onfocus, onblur, onkeyup (lowercased why??)
nor FilteringSelect?.js onkeyup (lowercased ??)
nor TimeTextbox? onfocus (lowercased ??)
nor Slider.js onMouseMove
nor ComboBox?.js onkeypress, onfocus, onblur, onmouseover, onmouseout (lowercased ??), onClose, onClick
nor Checkbox.js onClick
nor Textbox.js onfocus (lowercased ??)
nor Dialog.js onLoad, onOpen
These are just a quick scan, this problem is bigger than just changing 1 file, IMHO all widget creators must be aware of this and code accordingly.
I'm assigning this back to you Bill, you probably know how to assign issues in the files above.
/ Fredrik
comment:3 Changed 14 years ago by
Milestone: | 0.9 → 1.1 |
---|
- Most of those functions should have _ in front of them (like Menu.js).
- Button.js is not an issue because it's ok to override that function.
- ValidationTextBox?, FilteringSelect?, TimeTextbox? is using syntax like dojoAttachEvent="onfocus" rather than dojoAttachEvent="onfocus:_onFocus" but that makes the functions seem public so we should probably change it
and so forth. Will fix for 1.1
comment:4 Changed 14 years ago by
comment:5 Changed 13 years ago by
Bill, I wonder if using attributemap (#3058) cascading the parsed handler with the template handler, the way we do with class and style attributes, might help here.
comment:6 Changed 13 years ago by
Priority: | high → normal |
---|---|
severity: | critical → minor |
comment:7 Changed 13 years ago by
PS: I marked this as low priority because the user can now easily connect to a method rather than overriding it by doing a <script type="dojo/connect" event="onShow"> ...
comment:8 Changed 13 years ago by
Milestone: | 1.1 → 2.0 |
---|
comment:10 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.3 → 2.0 |
comment:11 Changed 10 years ago by
The issue is that sometimes the specified function is intended to overwrite, rather than connecting. The two examples I've found are dijit.form.Form (onSubmit), and dijit.form.Button (onClick). In both cases the function returning false will cancel the form submit.
comment:12 Changed 8 years ago by
Priority: | high → low |
---|
comment:13 Changed 6 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
This is effectively fixed in delite/deliteful, since events like show/hide are emitted as actual events, and there aren't callback methods. So, closing this as fixed in 2.0.
Right, doing onShow=... in the parser does a replace rather than a connect by design, so that you can define a function that returns a value, like
or something like that.
So we need to change onShow to _onShow and make onShow empty, like:
Can you do this?