PDA

View Full Version : Reset the div-tag



metan
16 Sep 2010, 12:16 PM
Hi,

After overwriting a div tag via ajax, I would like the set it back to it original content.


//Gets different content via Ajax
function getConEl(shDivId, shConElId) {
shDivId = Ext.get(shDivId);
if((shDivId != null) && (shConElId > 0)) {
shDivId.load({
url: "index.php",
params: "eID=sh_getConEl&shConElId=" + shConElId,
text: "Get data..."
});
shDivId.show();
}
else {
shDivId.remove();
}
}
Using remove is wrong, but I don't found some "reset" for div-tags.

Thanks in advance for any kind of help.

Regards
Metan

StuartAshworth
17 Sep 2010, 1:03 AM
By loading new content you are discarding what was there before and i'm fairly certain that an 'archive' of previous content is not kept. You will have to cache the original content somewhere and then re-insert it manually.

metan
17 Sep 2010, 12:49 PM
Hi,

I have changed some things.


function get_shConEl(shDivIdName, shConElId, onOff) {
var shDivId = Ext.get(shDivIdName);
var shDivIdTmp = shDivIdName + '_' + shConElId;
var shDivIdTmpId = Ext.get(shDivIdTmp);

if(Ext.get(shDivIdTmp) == null){
if((shDivId != null) && (shConElId > 0) && (onOff == 1)) {
Ext.DomHelper.insertAfter(shDivId, {
tag: "div id='" + shDivIdTmp + "'",
html: ("Zusätzlicher Inhalt<br /><a href=\"javascript:get_shConEl('testId', 643, 0)\">reset</a><br />")
});
Ext.get(shDivId).dom.style.display = 'none';
}
}

if((shDivId != null) && (shConElId > 0) && (onOff == 0)) {
shDivIdTmpId.remove();
Ext.get(shDivId).dom.style.display = 'block';
}

}Ho can I add an ajax loaded content to the new node.



shDivId.load({
url: "index.php",
params: "eID=sh_getConEl&shConElId=" + shConElId
});
shDivId.show();
Is something like that possible.

Metan

metan
19 Sep 2010, 11:50 PM
Hi,

sometimes it is to easy to see the solution.
Thats the way how it works:


function get_shConEl(shDivIdName, shConElId, onOff) {
var shDivId = Ext.get(shDivIdName);
var shDivIdTmp = shDivIdName + '_' + shConElId;
var shDivIdTmpId = Ext.get(shDivIdTmp);

if(Ext.get(shDivIdTmp) == null) {
if((shDivId != null) && (shConElId > 0) && (onOff == 1)) {
var newDivId = Ext.DomHelper.insertAfter(shDivId, {
tag: "div id='" + shDivIdTmp + "'"
});

newDivId = Ext.get(newDivId);
newDivId.load({
url: "index.php",
params: "eID=sh_getConEl&shConElId=" + shConElId
});
Ext.get(shDivId).dom.style.display = 'none';
newDivId.show();
}
}

if((shDivId != null) && (shConElId > 0) && (onOff == 0)) {
shDivIdTmpId.remove();
Ext.get(shDivId).dom.style.display = 'block';
}
}