Opened 9 years ago
Closed 5 years ago
#14447 closed defect (patchwelcome)
mvc.Repeat ignores widgets created by first parser run
Reported by: | Stefan Meyer | Owned by: | Ed Chatelain |
---|---|---|---|
Priority: | high | Milestone: | 1.11 |
Component: | DojoX MVC | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When the parser parses the template and creates the widgets, it also creates widgets for children of a Repeat-Widget. These will be discarded and replaced by the Repeat-Widget. The orignally created widgets hang around though and can be retrieved by calling dijit.byId. This causes a duplicate id problem when you dispose the widget and create it again from the template and define dynamical ids like :
id="idInput#{this.index}
Change History (7)
comment:1 Changed 9 years ago by
comment:3 Changed 9 years ago by
Unfortunately stopParser does not work inside a _Templated widget because it is overridden by the template=true property of the parser.
comment:4 Changed 8 years ago by
I have encountered this problem too. You can see a test file (based on dojox/mvc/tests/test_templatedWidget/test_mvc_widget.html) at:
The patch to make the test case is:
*** dojox/mvc/tests/test_templatedWidget/test_mvc_widget.html 2012-12-18 09:54:17.000000000 +1100 --- dojox/mvc/tests/test_templatedWidget/test_mvc_widget_destroy.html 2012-12-18 12:35:28.000000000 +1100 *************** *** 15,20 **** --- 15,21 ---- "dojox/mvc/getStateful", "dojox/mvc/ModelRefController", "dojox/mvc/tests/test_templatedWidget/myMvcTemplated", + "dijit/form/Button", "dojo/domReady!" ], function(parser, getStateful, ModelRefController, myMvcTemplated){ ctrl = new ModelRefController({model: getStateful([ *************** *** 57,62 **** --- 58,65 ---- <div> Test exprchar. Widget template test uses exprchar of # and others for template:#{this.index} etc. </div> + <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ require('dijit/registry').byId('container2').destroyRecursive(false); }">Destroy Widget</button> + <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ alert(require('dijit/registry').byId('nameInput#{this.index}')); }">Check registry</button> <br/> <div id="container2" data-dojo-type="dojox.mvc.tests.test_templatedWidget.myMvcTemplated" data-dojo-props="ctrl: ctrl"></div> </div>
The second button shows that registry.byId('nameInput#{this.index}') returns a widget before and after the templated widget is destroyed (destroy it with the first button). As stemey said this means if you try to destroy the widget then create it again you get an error like:
Error: Tried to register widget with id==nameInput#{this.index} but that id is already registered http://amertec.digiwise.com.au/client/src/dijit/registry.js Line 28
comment:6 Changed 8 years ago by
Thanks for the testcase. I am on vacation until early January so I will not be able to work on this until I return.
comment:7 Changed 5 years ago by
Milestone: | tbd → 1.11 |
---|---|
Resolution: | → patchwelcome |
Status: | new → closed |
dojox/mvc is not actively maintained. If someone wants to work on pull requests for the issues, we'll consider them.
Sounds like there are a number of problems, but you might want to start off by defining mvc.Repeat.stopParser = true, so that the parser doesn't parse the contents. inside the Repeat widget.