I am trying to re-append some div´s after detaching but it is not working for hours now...i can´t find my mistake...
Sitution:
There is an input field with a livesearch function ( onkeydown ).. On the function i am querying for some data. lets say my orginal page without livesearch has got 2 divs:
div id="a"
and div id="b"
after the livesearch there is one more div id="c"
...
I only want to display the id="c" but keep the id="a" and id="b" ( but not showing them to the user) .. I can not user hide() and show() because this will damage the applications on the div´s..
I tried to use detach and appendTo.. The code is close to working .. but not 100% ..
I am wrapping the old divs into a class called old_div
All the new livesearch results get the class of livesearch_results
function livesearch(value){
var kasten = $('.original_div');
// first keydown
if($('.old_div').length == 0 && $('.livesearch_result').length == 0 ){
kasten.addClass('old_div');
var detached = $('.old_div').detach();
}
.... do the livesearch ... everything works fine ... but
if(value == ""){
$('.livesearch_result').remove();
detached.appendTo("#rechteSeite");
return;
}
___________________________________________
as it is a function it is calling an undefined variable detached if value == ""
... so to make that clear..everything works till the point where value == "" .. i just can not find a way to re append the old div id="a" and "b" , because the variable is undefined. within the function(on keypress)... declaring it again within this function is not working coz .old_div allready had been detached on the first keydown ... i really would appreciate some advice on that..
of corse its possible to suggest a different solution .. it s not compulsory to think only of detach and append .. but i am out of thoughts here:/ thank you very much