Good morning!
I have a query, for example:
$limit = $limitFirst+4;
$query = $sql->query('SELECT * FROM dc_store_products WHERE status = "1" ORDER BY `order` > "'.$limitFirst.'" ASC LIMIT '.$limit.'');
while($row = $sql->fetch($sql)){
// SHOW THINGS
}
<div class="load_projects" onclick="dp.project.loadmore('4');">
Load More
</div>
When i click on load_projects, he get's me more data from the query! The thing is, when i reach the end of the query, if i don't have new items to show up, i want to hide the load more! I don't know the best thing to do at this point, so some feedback will be nice :)
If you're using jQuery, never use the "onclick" attribute in HTML. Instead, do this:
var dp.project.loadmore = function(){
// function content
};
$('.load_projects').on('click', dp.project.loadmore);
Then, when you call dp.project.loadmore(), and if $row == 0 length, do this:
$('.load_projects').off('click', dp.project.loadmore ).hide();
Note that I first add an event listener to the DIV element, then remove it again, and hide the DIV itself. You might like to do the tutorials in this link if you haven't already, as this is basic jQuery:
And please take 2 minutes to read this: