www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    Join Date
    Oct 2009
    Posts
    116
    anyone have any ideas?

  2. #17
    Join Date
    Jan 2009
    Posts
    3,343
    Did you see the post above yours? If you are wanting to change the button text it seems like that would do it.

  3. #18
    Join Date
    Oct 2009
    Posts
    116
    Been trying to get that to work for about 4 hours, cant get it to work...

  4. #19
    Join Date
    Nov 2010
    Posts
    956
    does the flag work as it should? put in a couple of alerts...
    Code:
    var postHandler = function(postsJSON) {
    var postsLocated = false;
    			$.each(postsJSON,function(i,post) {
    postsLocated = true;
    alert(postsLocated)//should alert true unless there are no more posts
    				//post url
    				var postURL = '' + domain + "test.php?ID=" + post.ID;
    				
    				var id = 'post-' + post.ID;
    				//create the HTML
    				$('<div></div>')
    				.addClass('post')
    				.attr('id',id)
                          //generate the HTML
                             .html('')
    				.click(function() {  
                    window.location = postURL;  
                })  
    				//inject into the container
    				.appendTo($('#posts'))
    				.hide()
    				.slideDown(250,function() {
    					if(i == 0) {
    						//$.scrollTo($('div#' + id));
    					}
    if(!postsLocated){
    alert(postsLocated)//if this alerts false ONLY when there are no more posts, you are on the right track
    }
    				});

  5. #20
    Join Date
    Oct 2009
    Posts
    116
    Thanks for the help!

    OK, I am getting the "true" alert every time I load a set. However I am not getting an alert when when I run to the end of the database.


    This is the section of the code that seems to not be working, does it look right?

    Code:
                    if(i == 0) {
    		   //$.scrollTo($('div#' + id));
    		}
    		if(!postsLocated){
                       alert(postsLocated)//if this alerts false ONLY when there are no more posts, you are on the right track
                    }
    			
    				});
    			});
    		};

    again thanks for the help

  6. #21
    Join Date
    Nov 2010
    Posts
    956
    hmm... maybe a small miscalculation on where the functions end Try this one:

    Code:
    var postHandler = function(postsJSON) {
    var postsLocated = false;
    			$.each(postsJSON,function(i,post) {
    postsLocated = true;
    alert(postsLocated)//should alert true unless there are no more posts
    				//post url
    				var postURL = '' + domain + "test.php?ID=" + post.ID;
    				
    				var id = 'post-' + post.ID;
    				//create the HTML
    				$('<div></div>')
    				.addClass('post')
    				.attr('id',id)
                          //generate the HTML
                             .html('')
    				.click(function() {  
                    window.location = postURL;  
                })  
    				//inject into the container
    				.appendTo($('#posts'))
    				.hide()
    				.slideDown(250,function() {
    					if(i == 0) {
    						//$.scrollTo($('div#' + id));
    					}
    				});
    		});
    	if(!postsLocated){
    alert(postsLocated)//if this alerts false ONLY when there are no more posts, you are on the right track
    }	
    });

  7. #22
    Join Date
    Oct 2009
    Posts
    116
    It works!!! Thank you! Now how to I get that to make the button say "we are done" .


    Again thank you so much!

  8. #23
    Join Date
    Nov 2010
    Posts
    956
    wouldn't that be like I posted before...

    Code:
    if(!postsLocated){ //there were no more posts
    $('#load-more').val('We are done'); //change text of button
    }
    ?

  9. #24
    Join Date
    Oct 2009
    Posts
    116
    so I replace

    Code:
    if(!postsLocated){
    alert(postsLocated)//if this alerts false ONLY when there are no more posts, you are on the right track
    }
    to this?

    Code:
    if(!postsLocated){ //there were no more posts
    $('#load-more').val('We are done'); //change text of button
    }
    It doesn't seem to work, seems I need to go lower where '#load-more' is defined


    Code:
    var start = <?php echo $_SESSION['posts_start']; ?>;
    		var desiredPosts = <?php echo $number_of_posts; ?>;
    		var loadMore = $('#load-more');
    but im pretty lost, as you can see. LOL

  10. #25
    Join Date
    Nov 2010
    Posts
    956
    sorry - I thought your were using jQuery. looks like the mooTools equivalent is:
    Code:
    if(!postsLocated){ //there were no more posts
    $('#load-more').set('text','We are done'); //change text of button
    }
    and yes - if the code was alerting correctly (ie, false only when there are no more posts), then that's the place to put it.

  11. #26
    Join Date
    Oct 2009
    Posts
    116
    No thats not working :-(

    and I have the jquery library loaded, i have never used mooTools

  12. #27
    Join Date
    Oct 2009
    Posts
    116

    Talking

    Changed it to

    Code:
                    if(!postsLocated){ //there were no more posts
    		loadMore.text('We are done here!');
    }
    and now it works


    Thank you, Thank you, Thank you!!! I really appreciate all the help and patience you gave.

  13. #28
    Join Date
    Nov 2010
    Posts
    956
    oh, yeah - ha, ha. load-more is a div, not a button - that's why .val() wasn't working

    glad you got it going!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles