1

I have a page which has dynamic content and its content changing with parameters.

I'm trying to comparison different department courses. First I select computer science and load its courses my first div at left. (#list1)

After load first content, I change department to industrial engineering and I click second button to load course list to second div (#list2)

But when i load second div first div content changes like second (industrial engineering). Bu if i load second div first its working! (But its not acceptable for client)

My code like this,

<div class="row">
<div class="col-md-12">
    <div class="col-md-6">
        <div id="list1"></div>
    </div>
    <div class="col-md-6">
        <div id="list2"></div>
    </div>
</div>
</div>

And button click events

$(document).on("click", ".btn-listele", function () {

        var direction = $(this).attr("data-taraf");
        var send2 = $.post("/Intibak/DersIntibak/CleanIntibakDers");
        send2.done(function () {
        if (direction == "sol") {
            $("#list1").load("/Genel/BolumPlan/IntibakDersPlan?guncelMi=true&groupable=true");
        }
        if (direction == "sag") {
            $("#list2").load("/Genel/BolumPlan/IntibakDersPlan?guncelMi=true&groupable=true");
        }
        });
    });

note: if I change div order like above then the problem reverse.

<div class="row">
<div class="col-md-12">
    <div class="col-md-6">
        <div id="list2"></div>
    </div>
    <div class="col-md-6">
        <div id="list1"></div>
    </div>
</div>
</div>

My button code

<span class="btn btn-info pull-right btn-listele" id="btn-listele-sol" data-taraf="sol">Ders Planlarını Listele</span>

<span class="btn btn-info pull-right btn-listele" id="btn-listele-sag" data-taraf="sag">Ders Planlarını Listele</span>
5
  • whether the first request returns an element with id list2 Commented Aug 4, 2015 at 6:23
  • Try alert($('[id="list2"]').length) before loading the second request Commented Aug 4, 2015 at 6:23
  • provide your button code. Commented Aug 4, 2015 at 6:28
  • @ArunPJohny i tried different names it same. and the alert return zero. Commented Aug 4, 2015 at 6:33
  • @Chayan i added my button code. Commented Aug 4, 2015 at 6:33

2 Answers 2

1

Script Execution

When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the script blocks before they are discarded. If .load() is called with a selector expression appended to the URL, however, the scripts are stripped out prior to the DOM being updated, and thus are not executed. An example of both cases can be seen below:

Here, any JavaScript loaded into #a as a part of the document will successfully execute.

$( "#a" ).load( "article.html" );

However, in the following case, script blocks in the document being loaded into #b are stripped out and not executed:

$( "#b" ).load( "article.html #target" );
Sign up to request clarification or add additional context in comments.

1 Comment

thanks i added my target page container div a id and put it my load code. it solved.
1

It appears that what you're loading into '#list1' and '#list2' comes from the exact same data source.

Is the result of /Genel/BolumPlan/IntibakDersPlan?guncelMi=true&groupable=true" ever different? If not, you will end up with the same data in each div.

1 Comment

that page has different contents. i am checking and its working good. before i click list button, i change the department.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.