Skip to content

clock example and require('moment') #31

@lutzbickhardt

Description

@lutzbickhardt

Hi!

Have been trying to run the clock example stand alone, these are my (slightly modified) files:

<title>Ractive clock demo</title> <script src='ractive.js'></script> <script src='ractive-load.js'></script> <script src='moment.js'></script> <script type="text/javascript" src="main.js"></script>

// main.js -> create our clock...
var baseView;
Ractive.load( 'baseView.html' ).then( function ( BaseView ) {
baseView = new BaseView({
el: 'main',
data: { datetime: new Date()}
})
});

var i= 0;
setInterval(function () {
if (i%2 == 0) console.log("tick");
else console.log("tack");
i++;
baseView.set('datetime', new Date() );
}, 1000);

baseView.html and clock.html unmodified (except for not using a Capital letter in front)

All the below will be obvious to you, but it took me a lot of time to figure out ->

  1. issue: can you add this to the doc, so people do not have to guess/dig how it is done standalone without the Gist?
  2. issue: I was reading about in https://github.com/ractivejs/ractive-load and tried to use variations of Ractive.load.modules.moment = moment, but in vain. Finally I just loaded it (i.e. the nodeJs-module moment) in index.html along with ractive.js. That worked! But why then "Ractive.load.modules"? Please explain and document how it should be done in my example or else which you can run stand-alone.

Otherwise great work! Thanks!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions