Dijit form fields not parsing on dojo.place after a dojo.des

I have a table in my form called table0 that has several dijit form controls in it. I also have an add and remove button to add a new table and remove the last table. Each new table will have an id incremented by 1. So the first click of add gives table1, 2nd click table2, etc. Each click of remove …

via Java Application Development Tutorial » Search Results » ajax:

Dijit form fields not parsing on dojo.place after a dojo.des

I have a table in my form called table0 that has several dijit form controls in it. I also have an add and remove button to add a new table and remove the last table. Each new table will have an id incremented by 1. So the first click of add gives table1, 2nd click table2, etc. Each click of remove will remove the last table.
Here is the add function:
function getNewTable()
dojo.query(‘#addTable’).onclick(function()
var tableNode = dojo.byId(‘table’+count);
count++;
dojo.xhrGet(url: ‘addTable.html’,
handleAs: “text”,
preventCache: true,
content:fieldId:count ,
load: function(data)
var newTable = dojo.place(data, tableNode, ‘after’);
dojo.parser.parse(newTable);
,
error: function(error)
var newTable = dojo.place(“AJAX error: ” + error, deductNode, ‘after’);
dojo.parser.parse(newTable);

});
});
}The remove function is :
function removetable()
dojo.query(‘#removeTable’).onclick(function()
if (count != 0)
var tableNode = dojo.byId(‘table’+count);
count–;
dojo.xhrGet(url: ‘removeTable.html’,
handleAs: “text”,
preventCache: true,
content: fieldId:count,
load: function(data)
dojo.destroy(tableNode);
,
error: function(error)
var newTable = dojo.place(“AJAX error: ” + error, tableNode, ‘after’);
dojo.parser.parse(newTable);

});
}
});
}The count variable is declared globally.
The functions work correctly.
The problem I am having is when you remove a tableNode and then add a table node the node at that specific index will not execute dojo.parser.parse(newTable).
I put some output statements in my code to debug and all the references are correct.
So it works fine as long as you do not place a node with an id that has been destroyed.
Example: click add, table1 id is created, dojo parses it fine, all is well. click remove, table1 is destroyed, still ok. click add again, table1 is created, dojo does not parse this node.
Am I doing something wrong?
……………………………………

Looks like I did not destroy the dijit widgets correctly.
I added this inside the load callback of the remove function:
dojo.forEach(dijit.findWidgets(dojo.byId(deductNode)), function(w)
w.destroyRecursive();
);
dojo.destroy(deductNode); I assumed destroying the dom node with dojo.destroy would also remove the dijit widgets.
This is working correctly now.

For more info: Dijit form fields not parsing on dojo.place after a dojo.des

Java Application Development Tutorial » Search Results » ajax

Dijit form fields not parsing on dojo.place after a dojo.des

Share this post:

Related Posts

Leave a Comment