ractivejs / ractive-load

Import templates and components using AJAX
ractivejs.github.io/ractive-load
MIT License
55 stars 10 forks source link

clock example and require('moment') #31

Open lutzbickhardt opened 9 years ago

lutzbickhardt commented 9 years ago

Hi!

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

Ractive clock demo

// 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!!!

lutzbickhardt commented 9 years ago

sorry, hope this works, index.html -> :