Skip to content

Commit

Permalink
Fix Array of objects example in index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
TxHawks committed Dec 28, 2015
1 parent 2951df6 commit e5ba0c0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ <h2>Working with an array of objects</h2>
<label class="">Search for one of Lea's projects: <input type="text"></label>

<pre class="language-javascript"><code> <script>
var arrOfObj = document.querySelector('#array-of-objects');
var arrOfObj = document.querySelector('#array-of-objects input');

new Awesomplete(arrOfObj {
new Awesomplete(arrOfObj,{
list: [
{
"name": "Awesomplete",
Expand All @@ -412,9 +412,12 @@ <h2>Working with an array of objects</h2>
"url": "https://leaverou.github.com/chainvas"
}
],
filter: function(text, input) {
return Awesomplete.FILTER_CONTAINS(text.name, input)
},
item: function(item, input) {
var html = item.name.replace(RegExp(Awesomplete.$.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>") +
", (item.url)";
" (" + item.url + ")";
return Awesomplete.$.create("li", {
innerHTML: html,
"data-url": item.url,
Expand All @@ -423,9 +426,9 @@ <h2>Working with an array of objects</h2>
}
});

arrOfObj.addEventListener('awesomplete-selectcomplete', fucntion(e) {
// You can no do something with e.originalTarget.getAttribute('data-*')
console.log(e.originalTarget.getAttribute('data-url');
arrOfObj.addEventListener('awesomplete-selectcomplete', function(e){
// Do something with e.originalTarget.getAttribute('data-*')
console.log(e.originalTarget.getAttribute('data-url'));
});
</script></code></pre>
</section>
Expand Down

0 comments on commit e5ba0c0

Please sign in to comment.