Skip to content

Commit

Permalink
Add docs link to README
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloVallejo committed Mar 8, 2014
1 parent 7466c20 commit 157b7b0
Showing 1 changed file with 2 additions and 96 deletions.
98 changes: 2 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,103 +14,9 @@ Include jQuery, Gillie and your app scripts.
<script src="js/yourapp.js"></script>
```

## Overview
## Documentation

Gillie follows a `handler-model-view` architecture in order to group app sections.

## Basic Usage

This example illustrates how to get user data and persist it on the server side in a RESTful way.

- Model


```js
// User model
var UserModel = Gillie.Model.extend({

// Defualt attributes
defaults: {
id: 0
, email: ''
, name: ''
}

// Base URL
, url: 'http://localhost/PHP/laravel/public/api/v1/'

// Save user
, save: function() {

// Make a "POST" request passing the actual user's "id", save it
// and trigger "user.save" event on success.
this.Put( 'users/:id', 'user.update' );
}
});

var userModel = new UserModel();
```

- Handler

```js
// User handler
var UserHandler = Gillie.Handler.extend({

// Element to bind from
el: 'body'

// Bind events to elements
, events: {
'click .update-user': 'updateUser'
}

, updateUser: function( e ) {
e.preventDefault;

var email = $( '.user-email' ).val()
, id = $( '.user-id' ).val()
, name = $( '.user-name' ).val();

// Set user attributes on model and save
userModel.set({
id: id
, email: email
, name: name
}).save();

}

});

// Instantiate handler
var userHandler = new UserHandler();

```

- View

```js
// View
var UserView = Gillie.Model.extend({

initialize: function() {

// Bind to user save event
userModel.on( 'user.update', this.showNotification );
}

// Show an alert after user is saved
, showNotification: function( model, response ) {

var name = model.get( 'name' );
alert( 'Howdy ' + name + ' your account has been updated.' );
}

});

var userView = new UserView();
```
Library documentation and examples can be found in the [project page](http://pablovallejo.github.io/gillie/)

## Contributing

Expand Down

0 comments on commit 157b7b0

Please sign in to comment.