SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2010
    Location
    Eindhoven
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery slider disable click on slider

    I've got the following problem:

    I have a Jquery slider and I want to disable the click on the slider.
    I only want to change the slider when I click and drag the pointer.
    Standard you can also click everywhere on the slider and the pointer will go to that point. That I don't want. .

    Can someone help me?

    This is the code:

    Code HTML4Strict:
    <!DOCTYPE html>
    <html>
    <head>
    	<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
    	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    	<style type="text/css">
    		div.demo { padding: 10px !important; };
    	</style>
    	<script type="text/javascript">
    	$(function() {
    		$("#slider-range-max").slider({
    			range: "max",
    			min: 1,
    			max: 10,
    			value: 2,
    			slide: function(event, ui) {
    				$("#amount").val(ui.value);
    			}
    		});
    		$("#amount").val($("#slider-range-max").slider("value"));
    	});
    	</script>
    </head>
    <body>
     
    <div class="demo">
        <p>
            <label for="amount">Minimum number of bedrooms:</label>
            <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
        </p>
        <div id="slider-range-max"></div>
    </div>
     
    </body>
    </html>

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you could try is first unbind click events attached to your element, then bind new functionality onto it, something like:
    $('.myButton').unbind('click');
    $('.myButton').bind('click', function() {
    ....
    });

  3. #3
    SitePoint Member
    Join Date
    Apr 2010
    Location
    Eindhoven
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your solution TommiChi, but it seems that this solution doesn't work. Or can you give the script code how you should change it?
    Anyone got another solution?

  4. #4
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mark,

    I am facing the issue. I want to disable the click event on jquery slider. Have you got any solution yet? Please help me.

    Thanks,
    Ads

  5. #5
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Mark Kurvers View Post
    Thanks for your solution TommiChi, but it seems that this solution doesn't work. Or can you give the script code how you should change it?
    Anyone got another solution?
    How were you adding the jQuery to the page, were you adding it using jQuery's document .ready() method?
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle


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
  •