1.0.27 • Published 7 years ago

all.js v1.0.27

Weekly downloads
30
License
ISC
Repository
-
Last release
7 years ago

Install

$ npm install all.js

Usage

Model example

import Model from "all.js/model";


class Post extends Model {
    static getUrlConfig() {
        var base = "http://localhost:8000/api/";
        return {
            CREATE: base + "posts/",
            GET: base + "posts/<id>",
            ALL: base + "posts/",
            UPDATE: base + "posts/<id>",
            DELETE_ONE: base + "posts/<id>",
            DELETE_ALL: base + "posts/"
        }
    }
}


// Create model
var example = new Post();
example.text = "Example text";
example.save();

// Retrieve one
Post.get(id = 0, function (post) {
    console.log(post);
});

// Retreve all
Post.all(function (posts) {
    console.log(posts);
});

Template example

import Model from "all.js/model";
import Template from "all.js/template";

class ExampleTemplate extends Template {

    getTemplateUrl() {
        return "template.html";
    }

    load(element) {
        this.render(element, {
            data: "Example data"
        });
    }
}

var template = new ExampleTemplate();
template.load('body');
<html>
<head>
</head>

<body>
<h1 data-bind="data -> text"></h1>
</body>

</html>

Router example

import Model from "all.js/model";
import {Router, setRouter} from "all.js/router";
import Template from "all.js/template";

class ExampleTemplate extends Template {

    getTemplateUrl() {
        return "template.html";
    }

    load(element) {
        this.render(element, {
            data: "Example data"
        });
    }
}


var router = new Router('body');
router.registerRoute("home", new ExampleTemplate());
setRouter(router);
1.0.27

7 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago