Skip to content

Commit

Permalink
Fix and and add more information to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
StefansArya committed Jan 24, 2019
1 parent 099815d commit c3e0363
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ sf.router.goto('/user/home', data = {}, method = 'get');

Define event listener when element with attributes `sf-page="todo/page"` was loaded to current DOM. The defined event will being called after all model and controller was finished.
```js
sf.router.before('todo/page', function(ModelRoot){
sf.router.before('todo/page', function(root){
// Data Re-initialization
var self = ModelRoot('todo.page'); // sf.model.root['todo.page']
var self = root('todo.page'); // sf.model.root['todo.page']
});
```

Define event listener when element with attributes `sf-page="todo/page"` is going to be removed from DOM.
```js
sf.router.after('todo/page', function(ModelRoot){
sf.router.after('todo/page', function(root){
// Data cleanup
});
```
Expand All @@ -123,6 +123,19 @@ sf.router.on('error', function(e) {
});
```

When you're using router, every click on an element with link or `href` will trigger the router feature. And the whole HTML `body` content will be changed. But if you only want to change specific content, you should define the default view point.

```html
<custom-view></custom-view>
<script>
sf.router.lazyViewPoint["@default"] = 'custom-view';
</script>

<a href="/todo/page">Go to todo page</a>
<a href="/todo/page" sf-router-ignore>Default page load</a>

```

### Controller
Controller is used for controling your model, so this would have a list of your static function.

Expand Down Expand Up @@ -265,7 +278,7 @@ These addional feature can be used after DOM element was binded.
#### hardRefresh
Redraw all element at once
```js
myArray..hardRefresh();
myArray.hardRefresh();
```

#### softRefresh
Expand Down Expand Up @@ -372,7 +385,7 @@ var $elem = $(elements);
self.list.$virtual.scrollTo(8);

// Recalculate scroll bounding
self.list.$virtual.refresh(8);
self.list.$virtual.refresh();

// This will be available on static element height
// Get an offset that can be used for `scrollTop`
Expand Down

0 comments on commit c3e0363

Please sign in to comment.