This is a migrated thread and some comments may be shown as answers.

Unable to set Navbar title

3 Answers 234 Views
NavBar
This is a migrated thread and some comments may be shown as answers.
Chris Whisker
Top achievements
Rank 1
Chris Whisker asked on 05 Sep 2012, 01:06 PM
Hi,

I have a listview that when an item is clicked an overlay view is displayed. When the overlay is shown I want to be able to change the Navbar title. However this is not working when I use the code listed in the documentation.

The HTML code I have for the overlay is: 

<div data-role="view" data-title="View Title" id="fav-list" data-transition="overlay:up">
    <header data-role="header">
        <div id="fav-list-navbar" data-role="navbar">
            <a class="nav-button" data-align="left" href="#my-favourites" data-transition="overlay:up reverse" data-role="backbutton" >Back</a>
            <span data-role="view-title"></span>
        </div>
    </header>
            
</div>


and the javascript that relates to the listview and the changing of the navbar title: 

function mobileListViewHeadersInit() {
 
        $("#myfavlist").kendoMobileListView({
 
            dataSource: kendo.data.DataSource.create({data: jsonObj, group: "letter" }),
 
            template: $("#myfavlistTemplate").html(),
 
            headerTemplate: "${value}",
 
            fixedHeaders: true,
             
            click: function(e) {
                 
                try {
                $("#fav-list-navbar
"
).data("kendoMobileNavBar").title("Foo");
                }
                catch(ee)
                {
                    alert("Error: " + ee.message);
                }
                 
                window.location = "#fav-list";
                 
                //alert(e.dataItem.name);
            }
 
        });
 
    }

The error message i receive when this is run is: 

'undefined' is not an object. 

However if I use jquery to look up any of the elements, they are accessable

Not sure what to try next.....


Chris

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 05 Sep 2012, 01:27 PM
Hi Chris,

Your code looks ok. Based on it, I made this jsFiddle (using button, but the idea is the same). The title changes when the button is clicked. 

Is it possible for you to modify the provided sample, in order to demonstrate the issue you are facing? Thanks. 

All the best,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Chris Whisker
Top achievements
Rank 1
answered on 05 Sep 2012, 01:42 PM
Petyo

I have updated the code to demonstrate my problem: http://jsfiddle.net/M5FHN/1/

The problem happens when you click on the item in the middle tab

Regards

Chris
0
Accepted
Petyo
Telerik team
answered on 05 Sep 2012, 02:10 PM
Hi Chris,

Thanks for the provided sample. The problem in this case is that you are trying to access a widget in a another view which is not initialized yet (and the widget in it is not, too).

The recommended way to achieve that would be to pass a view parameter to the view you navigate to, and handle it in the target view show event handler. You can check the corresponding documentation on how to access view parameters.

You may also consider suggesting your company license holder to add you as a licensed developer for Kendo UI. This will allow you to open tickets, which have 24 hour guaranteed response time. 

Kind regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
NavBar
Asked by
Chris Whisker
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Chris Whisker
Top achievements
Rank 1
Share this question
or