Jump to:

23355 Posts in 17691 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Simply load pages with AJAX - Tutorial?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 909 Views
  • oleze
    Avatar
    Community Member
    64 Posts

    Simply load pages with AJAX - Tutorial? Link to this post

    I was wondering if there is any simple tutorial to load all pages via AJAX if JavaScript is present. The only thing I'd like to do is to not load the whole page (and the viewport to be white) when the user clicks onto a menu link. Has anybody done that yet?

    Greatz
    Oliver

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Simply load pages with AJAX - Tutorial? Link to this post

    It's certainly doable but it's a rather bad idea. If you're switching from one page to another AJAX kind of loses it's purpose. The idea is to be able to switch or update certain elements of a page without having to make the whole round trip to the server but if you're loading a totally new page then that round trip is justified.

    What you could do, if you're really really sure that you want to do this is to put an index() method in your controller. In that index method you check if Director::is_ajax() and if it is you just render the Layout template and not the rest. If it's not an AJAX request then you render all of it like you usually do.

  • oleze
    Avatar
    Community Member
    64 Posts

    Re: Simply load pages with AJAX - Tutorial? Link to this post

    I think that's exactly what I want to do. In this case, the page type is the same so all of the scripts, css-files and so on can be the same, only the content-box would have to be loaded. I'll try the index-function you mentioned. Thanks.

  • TechticSolutions
    Avatar
    Community Member
    1 Post

    Re: Simply load pages with AJAX - Tutorial? Link to this post

    I was same problem faced. now i have read these an solved.....

    thanks for sharing....

    909 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.