Skip to content

Commit

Permalink
Merge pull request #15 from craigweston/gh-pages
Browse files Browse the repository at this point in the history
Updated gh page to contain ajax support (Issue #13)
  • Loading branch information
lodev09 committed Dec 14, 2015
2 parents 8e8a681 + a5f7602 commit 7cdb207
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ <h2 id="demo">Demo</h2>
}
}
})
```

### Init (with Ajax)
Ajax is supported by having the data function return a <a href="http://api.jquery.com/Types/#jqXHR">jqXHR</a> object. The function takes a single parameter containing the mention text string.

```javascript
$('#comment').suggest('@', {
data: function(q) {
if (q && q.length >= 3) {
return $.getJSON("users/lookup.json", { q:q });
}
},
map: function(user) {
return {
value: user.username,
text: '<strong>'+user.username+'</strong> <small>'+user.fullname+'</small>'
}
}
})
```

</div>
Expand All @@ -115,7 +134,7 @@ <h2 id="api">API</h2>
### Options
| option | type | default | description |
| -- | --- | --- | --- |
| data | array | [] | an array of objects or string |
| data | array/function | [] | an array (of objects or string) or a callback function |
| map | callback | _undefined_ | a callback function that is used to map the display and value of each item |
| filter | object | { casesensitive: true, limit: 5} | option that will let you set the filter behaviour |
| onshow(e) | event callback | _none_ | triggered when the dropdown is shown |
Expand Down

0 comments on commit 7cdb207

Please sign in to comment.