app.navigate in MVC

3 posts, 1 answers
  1. Answer
    Gert
    Gert avatar
    1 posts
    Member since:
    Apr 2012

    Posted 10 Dec 2013 Link to this post

    I have been searching for how to do this, but am unable to find the right answer.

    In JavaScript I can do this:

    var app = new kendo.mobile.Application();

    Then use the app variable to navigate between pages.

    But how do I do this in MVC? I can't set the MVC razor tag to a JavaScript variable, so how do I call .navigate after doing:

    @(Html.Kendo().MobileApplication()
            .Name("KendoMobileApplication")
            .PushState(true)
            .Transition("slide")
            .ServerNavigation(false)
            .Layout("databinding")
            )

    I have tried this, but it seems less than ideal that I create a new application every time I navigate:

    var app = new kendo.mobile.Application();
    app.navigate("/Home/AccountType");

    I've also tried

    $("#KendoMobileApplication").context.navigate("/Home/AccountType");

    But that doesn't work. It has no navigate method.

    So what is the correct way of doing this?
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 10 Dec 2013 Link to this post

    Hi Gert,

    You can get a reference of the already created application using this approach and then you can use the navigate() method to perform navigation:

    http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/mobileapplication/overview#getting-reference-to-the-kendo-ui-mobileapplication-widget

    Please keep in mind that it is really important not to create more than one mobile applications in your project, as this can cause multiple errors and unexpected behavior.

    Regards,
    Kiril Nikolov
    Telerik
    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. Gert
    Gert avatar
    1 posts
    Member since:
    Apr 2012

    Posted 11 Dec 2013 Link to this post

    Thanks! That was exactly what I was looking for, but was unable to find. Now it works as expected :)
Back to Top