swapping the content across DIV elements not working

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

swapping the content across DIV elements not working

Jaykanda
Hi Folks,

Basically I am doing the content swapping here, the content swapping happening fine for the children DIVs till I swap the whole parent DIV, once I swap the parent DIVs ... only parent DIV content swapping is happening always, the swap function is not working for the children DIVs , I dont have any clue why this is happening please let me know if anybody know the root cause of the problem, any problem with using of innerHTMLs inside my function..

please let me know issue here and how to overcome this issue.

Markup
--------

<div class="parentSIP" style="background: #ff9900;">
                    <div class="dragSlot sh slot23">2_3</div>
                    <div class="dragSlot sh slot22">2_2</div>
                    <div class="dragSlot sh slot21">2_1</div>
                    <div class="dragSlot sh slot20">2_0</div>
                </div>
                <div class="parentSIP" style="background: #ff9900;">
                    <div class="dragSlot sh slot13">1_3</div>
                    <div class="dragSlot sh slot12">1_2</div>
                    <div class="dragSlot sh slot11">1_1</div>
                    <div class="dragSlot sh slot10">1_0</div>
                </div>
                <div class="parentSIP" style="background: #ff9900;">
                    <div class="dragSlot sh slot03">0_3</div>
                    <div class="dragSlot sh slot02">0_2</div>
                    <div class="dragSlot sh slot01">0_1</div>
                    <div class="dragSlot sh slot00">0_0</div>
                </div>
            </div>

JS:
===

 var tmpEl = null;
            var tmpStr = "";
            function swap(el) {
                if(tmpEl) {
                    var tmpH = $(tmpEl).height();
                    var starteleH = $(el).height();
                    if(tmpH != starteleH) {
                        var id = $(el).attr("id");
                        var tmpOvId = $(tmpEl).attr("id");
                        var overlayId = $("div.overlayDiv_DnD").attr("id");
                        alert("Single and Double Height are irrelevant");
                        el.innerHTML = el.innerHTML;
                        tmpEl.innerHTML = tmpEl.innerHTML;
                    }
                    else {
                        alert("Slots are relevant here");
                        str = el.innerHTML;                        
                        tmpEl.innerHTML = str;
                        el.innerHTML = tmpStr;  
                    }
                    tmpEl = null;
                }
                else
                    tmpEl = el;
                tmpStr = el.innerHTML;
            }

            $("div.parentSIP,div.dragSlot").click(function(e){
                e.stopPropagation();
                e.cancelBubble = true;
                swap(this);              
            });