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

Get id of current view

3 Answers 698 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 19 Dec 2012, 01:00 AM
How can I get the id of the current view?

So for the code example below, it should alert "page_introduction". 

Example:
<div data-role="view" data-layout="app" data-title="My App" id="page_introduction" data-transition="fade">
content
</div>

<script>
alert("You are currently watching "+app.view.id());
</script>

3 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 19 Dec 2012, 07:26 PM
Hello Robin,

I believe the used code snippet does not work, because the () brackets of the view() method are set after the id. The correct syntax to get the view's id is:
alert("You are currently watching "+app.view().id);

Regards,

Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Manuel Henry II
Top achievements
Rank 1
answered on 24 Apr 2013, 09:21 AM
I cannot get the current view .

It returns an error TypeError: 'undefined' is not an object (evaluating 'this.pane.view')


<html><head>
    <title>Details View</title>
    <link href="css/kendo.mobile.all.min.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="css/main.css">
  
    <script src="js/jquery.min.js"></script>
    <script src="js/kendo.all.min.js"></script>
  
      
</head>
<body>
      
    <div data-role="view" id="detailsPage"  data-title="Details">
        this is a details page
    </div>
  
  
  
  
  
  
<script>
    var app = new kendo.mobile.Application(document.body);
        var item = app.view().id;
        alert(item);
</script>
</body>
</html>
0
Petyo
Telerik team
answered on 25 Apr 2013, 07:17 AM
Hello Robin,

The mobile application is fully initialized after the document.ready event passes - this is the reason why you experience this error.

As our documentation suggests, the recommended place to implement your application logic and view manipulation woud be in the respective view init/show events, where the views and widgets are fully initialized and functional. 

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!
Tags
General Discussions
Asked by
Robin
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Manuel Henry II
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or