SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 34 of 34
  1. #26
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,119
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You could change the .hide()/.show() to be .attr('disabled', 'disabled') and .removeAttr('disabled') respectively.
    http://jsfiddle.net/cpradio/qJzfP/5/

  2. #27
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Sikwondo View Post
    is there a way with jQuery to strip anchor tags from HTML? I was thinking, instead of removing the previous/next buttons when the user is at the start/end of the gallery list, to just remove the HTML so I could style the inactive links.
    It is more appropriate to set a class name on the inactive links, so that they can then be styled in an appropriate manner, whether that be hiding them, greying them our, or applying some other presentational aspect to them.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #28
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,119
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Setting a classname wouldn't prevent them from being clicked, by applying the disabled attribute, the user can't invoke the click event.

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by cpradio View Post
    Setting a classname wouldn't prevent them from being clicked, by applying the disabled attribute, the user can't invoke the click event.
    Setting a class name allows you to set their display to be hidden, which completely prevents them from being clicked at all. That is one of the most appropriate ways to deal with the situation.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,119
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Setting a class name allows you to set their display to be hidden, which completely prevents them from being clicked at all. That is one of the most appropriate ways to deal with the situation.
    True, but I was under the impression he wanted to style it, so I guess that would work too, but that isn't any different than using show or hide

  6. #31
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by cpradio View Post
    True, but I was under the impression he wanted to style it, so I guess that would work too, but that isn't any different than using show or hide
    When for example the previous link is to be disabled, it can be as easy as setting the class name on the link, and having the click event for that link just return without doing anything.

    That way the link doesn't do anything, and the presentation of the link can be styled in any way that is desired.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #32
    SitePoint Evangelist Sikwondo's Avatar
    Join Date
    Sep 2005
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect! I did a mix of both, I used your code cpradio, but then also added a class so I could change the colour, border styling etc:

    Code:
    // if first gallery
                if ( curGal === 0 ) {
                    //$('button.prev').hide();
                    $('button.prev').attr('disabled', 'disabled').addClass('disabled');
                }
                else
                {
                    $('button.prev').removeAttr('disabled').removeClass('disabled');
                    //$('button.prev').show();
                }
    
                // if last gallery
                if ( curGal === galleries.length - 1 ) {
                    //$('button.next').hide();
                    $('button.next').attr('disabled', 'disabled').addClass('disabled');
                }
                else
                {
                    $('button.next').removeAttr('disabled').removeClass('disabled');
                    //$('button.next').show();
                }
    
    		});
    
    		// Hide the first gallery
    		//$('button.prev').hide();
    		$('button.prev').attr('disabled', 'disabled').addClass('disabled');
    Thanks again both of you.

  8. #33
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,119
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sikwondo View Post
    Perfect! I did a mix of both, I used your code cpradio, but then also added a class so I could change the colour, border styling etc:
    Can't argue with that

  9. #34
    SitePoint Evangelist Sikwondo's Avatar
    Join Date
    Sep 2005
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also set it so that if there is only one gallery UL, hide the pagination:

    Code:
    if ( galleries.length > 1 ) {
    			$('.paginate').show()
    		} else {
    			$('.paginate').hide()
    		}
    
    
    
    
    		// Listen for when one of the buttons us clicked
    		$('.paginate').find('button').on('click', function() {


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
  •