Unable to set Navbar title

4 posts, 1 answers
  1. Chris Whisker
    Chris Whisker avatar
    5 posts
    Member since:
    Jul 2009

    Posted 05 Sep 2012 Link to this post

    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
  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 05 Sep 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Chris Whisker
    Chris Whisker avatar
    5 posts
    Member since:
    Jul 2009

    Posted 05 Sep 2012 Link to this post

    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
  5. Answer
    Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 05 Sep 2012 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready