Hi,
I'm making a control to page through members of a Facebook group.
It retrieves a page of data from FB and displays it in a list with a
"More" button underneath.
When clicking on "More" it fetches the next page and displays the
results.
The problem is I can't figure out how to hide the "More" button when
it's clicked.
I can't hack it with jQuery to target the button's class because that
would hide all buttons with that class not the specific one that was
clicked.
Here's the template:
templateEngine.addTemplate("ko_fbMembersControl", "\
<div id=\"membersScroll\" style=\"overflow:auto; height:200px
\">\
{{each(i, item) data}}\
<div style=\"height: 80px; border-top:1px solid black;\">\
<img border=\"none\" src=\"
https://graph.facebook.com/$
{id}/picture\" />\
<p>\
${name}\
</p>\
</div>\
{{if (i+1)/5 == Math.floor((i+1)/5)}}\
<button class=\"moreButton\" data-bind=\"click:
function() {\
nextPage(function(response){\
scrollTop = $
('#membersScroll').scrollTop();\
for(i=0; i < response.length; i++){\
data.push(response[i]);\
}\
$('#membersScroll').scrollTop(scrollTop);\
$('.moreButton').hide();\
});\
}\">\
More\
</button>\
{{/if}}\
{{/each}}\
</div>\
");
Where it says:
$('.moreButton').hide();
I want this to be a reference to the actual clicked button instead.
How do I pass a reference to the clicked button into the handler? Is
there already a util for getting this?
Regards,
Ed