Skip to content

waxim/app.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

AppJS

All of the current MVC JS frameworks where FAR too complicated. So I made this super simple 'framework' for creating rapid MVC apps in JS.

Dependencies

Examples

Super simple example for example for displaying 'default' content.

app.extend("home",{
	
	/* test for required loaded modules before we load this one */
	require: ['models','controllers','views'],
	
    /* This is our 'constructor' */
    _construct: function(){
		
		/* add our views */
		app.views.add("home", "<h1>Welcome to Satmap</h1>");
		
        /* we can register a model */
        app.models.add("page",{ title: "", content: ""});

        /* we register a 'controller' */
        app.controllers.register({controller: "/", callback: 
			function(req){ 
				app.render(app.home.page());
			} 
		});
		
    },

    /* register a function to be used by out controller */
    page: function(){ 
        return app.views.show("home", app.models.get("page"));
    }

});

if the above is loaded app.home.page() will be triggered when the hashbang is empty.

an example to show model data in a rendered view.

app.extend("home",{
	
	/* test for required loaded modules before we load this one */
	require: ['models','controllers','views'],
	
    /* This is our 'constructor' */
    _construct: function(){
		
		/* add our views */
		app.views.add("home", "<h1><%= title %></h1><p><%= content %></p>");
		
        /* we can register a model */
        app.models.add("page",{ title: "Welcome to satmap", content: "there is some content here."});

        /* we register a 'controller' */
        app.controllers.register({controller: "/", callback: 
			function(req){ 
				app.render(app.home.page());
			} 
		});
		
    },

    /* register a function to be used by out controller */
    page: function(){ 
        return app.views.show("home", app.models.get("page"));
    }

});

will render the model values into our view. see _.js templating for more information.

Development

This project will progress as my use of it increases. Expect binding from objects to dom elements to be the next feature and the loading of remote 'views'.

I'll accept pull requests on nice features or bug fixes, but the aim of this project is to keep things lite. I'm not trying to build a replacement for ember.

About

Simple JS MVC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published