BaSha
BaSha

Reputation: 2406

Issue with setting label text after including external html using js

i have header.html

<div class="ui-bar ui-bar-b">
        <div class="center">
            <a href="#" data-role="button" data-inline="true" class="collapse_icon" data-mini="true"></a>               
            <label id="headerTextId"></label> 
        </div>  
</div>

and my main page where i'm including this file

<div data-role="page" id="page1">
   <div id="headerDiv">
   </div>   
</div>

and in <head></head>

<script type="text/javascript">
    $('#page1').live('pageinit', function (event, ui) {
         $('#headerDiv').load('../common/header.html').trigger("create");
         $('#headerTextId').text("label text"); //not working
    });
</script>   

header file is included successfully but label text is not set, i have also tried .html() instead .text() but not worked.

Upvotes: 1

Views: 102

Answers (1)

Try

A callback function that is executed when the request completes.

$('#headerDiv').load('../common/header.html',function(){
    $('#headerTextId').text("label text");
}).trigger("create");

.load()

Upvotes: 3

Related Questions