Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Javascript Best Practices

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1384 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    Javascript Best Practices Link to this post

    Hi again,

    I'm probably going to want some custom javascript added to my pages, and probably even some ajax.

    Now I'm familiar with using the YUI-library but I see that there's already quite some js ( scriptaculous, prototype ) involved in the CMS.

    Is there any place where I can read about the best way to use the js that's already there, or should I just include the other library that I'm used to work with?

    And maybe some info about using ajax with SS too...

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Javascript Best Practices Link to this post

    for the frontend-side of things, you're pretty much free to choose for yourself.
    some silverstripe-modules such as blog/pagecomments require prototype/scriptaculous, but they're automatically included.

    some info/coding conventions for using javascript with silverstripe (mostly backend-related):
    http://doc.silverstripe.com/doku.php?id=javascript
    http://doc.silverstripe.com/doku.php?id=coding-conventions&s=javascript

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Javascript Best Practices Link to this post

    Ok so I could just as well include the YUI-library I'm used to work with...

    Is it common to include this in the page_controller? and how.. ? or just add them to my page.ss.?

    Maybe there's some doku about it...?

    I guess that's my major problem. I spend more time searching for how to do stuff than on actually writing it. I'm bookmarking every useful page now to prevent loosing time searching for it

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Javascript Best Practices Link to this post

    class Page extends SiteTree {}
    class Page_Controller extends ContentController {
    function init() {
    parent::init();
    Requirements::javascript: 'mysite/javascript/yui.js');
    );
    }

    > I guess that's my major problem. I spend more time searching for how to do stuff than on actually writing it.
    we're always looking for ways to adjust the wiki to the different learning paths, and are thankful for any tips in this direction - especially on structuring the content on the doc.silverstripe.com startpage.

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Javascript Best Practices Link to this post

    Ok thanks a lot

    I've found it also on http://doc.silverstripe.com/doku.php?id=requirements&s=javascript%20required
    although that document doesn't say you have to call parent, init.. which can be confusing.

    I believe there's quite some documentation out there but it's hard to find sometimes. Maybe a clear link to http://doc.silverstripe.com/doku.php?do=index can be helpful to anyone starting from http://doc.silverstripe.com/doku.php.

    What I'd like to see more too is some good explanation of how everythings fits into eachother. I find myself having a hard time knowing when to use what.
    Like getComponents, ... there's this tutorial of many_many_examples (http://doc.silverstripe.com/doku.php?id=many_many-example) but that leaves a lot of questions on how to select from multiple tables, when to use DataObject::get instead of getComponent(s), etc.

    And maybe some more explanation about authentication, frontend registration etc... Now I'm facing the task of wrestling through the forum code to gain insight in it.

    I know it must be a lot of work to get good documentation, but I'm sure that it will make many people happy

    1384 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.