<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan Coughlin &#124; Web and Graphic Designer &#187; ui</title>
	<atom:link href="http://www.ryancoughlin.com/tag/ui/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryancoughlin.com</link>
	<description></description>
	<lastBuildDate>Fri, 26 Mar 2010 00:07:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Another jQuery UI Slider Example</title>
		<link>http://www.ryancoughlin.com/2009/09/12/another-jquery-ui-slider-example/</link>
		<comments>http://www.ryancoughlin.com/2009/09/12/another-jquery-ui-slider-example/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:03:14 +0000</pubDate>
		<dc:creator>Ryan Coughlin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.ryancoughlin.com/?p=501</guid>
		<description><![CDATA[First post in a very long time. Finally the summer is over and I am back at school for my last year. Now finally I have a lot of free time to work on this new layout and getting it solid, and getting back to blog posts to catch up on what I missed. 
The [...]


Related posts:<ol><li><a href='http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/' rel='bookmark' title='Permanent Link: Using the jQuery UI Slider'>Using the jQuery UI Slider</a> <small>Utilize the jQuery UI Slider to change CSS properties or...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/' rel='bookmark' title='Permanent Link: Create a jQuery Accordion &#8211; remain open after page load'>Create a jQuery Accordion &#8211; remain open after page load</a> <small>Quick fix to keep accordion section open after loading different...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/' rel='bookmark' title='Permanent Link: Working with the jQuery live function'>Working with the jQuery live function</a> <small>Find out how to use jQuery .live() and how it...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>First post in a very long time. Finally the summer is over and I am back at school for my last year. Now finally I have a lot of free time to work on this new layout and getting it solid, and getting back to blog posts to catch up on what I missed. </p>
<p>The jQuery UI Slider is one part of the jQuery UI collection that is really neat and can have many uses. So last year I created this jQuery UI Slider never posted about it and I figured now would be the best time. </p>
<p>I  wrote this <a href="http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/" target="_blank">tutorial</a> on using the slider close to a year ago.</p>
<p>Now I created another version of it, with some different styles, with full code examples as well. This will display the current value of the slider as you move up and down bar. <strong>Check out the <a href="http://www.ryancoughlin.com/demos/interactive-slider/" target="_blank">jQuery UI Slider</a> and start playing around with it.</strong></p>


<p>Related posts:<ol><li><a href='http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/' rel='bookmark' title='Permanent Link: Using the jQuery UI Slider'>Using the jQuery UI Slider</a> <small>Utilize the jQuery UI Slider to change CSS properties or...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/' rel='bookmark' title='Permanent Link: Create a jQuery Accordion &#8211; remain open after page load'>Create a jQuery Accordion &#8211; remain open after page load</a> <small>Quick fix to keep accordion section open after loading different...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/' rel='bookmark' title='Permanent Link: Working with the jQuery live function'>Working with the jQuery live function</a> <small>Find out how to use jQuery .live() and how it...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ryancoughlin.com/2009/09/12/another-jquery-ui-slider-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining Selectables And Draggables Using jQuery UI</title>
		<link>http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/</link>
		<comments>http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 19:59:36 +0000</pubDate>
		<dc:creator>Ryan Coughlin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[combining]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[selectable]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.ryancoughlin.com/?p=258</guid>
		<description><![CDATA[Learn how to work with both selectable and draggable with the jQuery UI to select and drag numerous elements around a web page. Great for Web 2.0 applications.


Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/01/22/jquery-timeout-function/' rel='bookmark' title='Permanent Link: jQuery Timeout Function'>jQuery Timeout Function</a> <small>A neat and simple way to creating a jQuery function...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/' rel='bookmark' title='Permanent Link: Using the jQuery UI Slider'>Using the jQuery UI Slider</a> <small>Utilize the jQuery UI Slider to change CSS properties or...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/12/20/jquery-search-and-highlight/' rel='bookmark' title='Permanent Link: jQuery Search And Highlight'>jQuery Search And Highlight</a> <small>Work with the jQuery framework to create a fast Ajax...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>There are two powerful and fun elements that the jQuery UI provides. When both of them work together you will be able to come up with some creative web application uses for them. The two I am going to be covering are:</p>
<ul>
<li><strong>UI Selectable</strong> &#8211; <a href="http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.selectable.html" target="_blank">Demo</a> &#8211; <a href="http://docs.jquery.com/UI/Draggables" target="_blank">Documentation</a></li>
<li><strong>UI Draggable</strong> &#8211; <a href="http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.draggable.html" target="_blank">Demo</a> &#8211; <a href="http://docs.jquery.com/UI/Draggables" target="_blank">Documentation</a></li>
</ul>
<p><span class="highlight">I am sure you all want to see what the final product will look like, <a title="View the final demo using selectables and draggables" href="http://www.ryancoughlin.com/demos/dragselect/index.html" target="_blank">check it out</a>.</span></p>
<p><span id="more-258"></span></p>
<p>To start working with the jQuery UI you are going to need to add the following files to the head of your document:</p>
<ul>
<li><strong>jquery-1.2.6.min.js</strong> &#8211; <em>the main core jquery framework</em></li>
<li><strong>ui.core.js</strong> &#8211; <em>the UI core javascript</em></li>
<li><strong>ui.draggable.js </strong>- <em>the draggable javascript</em></li>
<li><strong>ui.selectable.js</strong> &#8211; <em>the selectable javascript</em></li>
</ul>
<p>Before we get started let me just say, <span class="highlight">thanks a ton to Richard Worth who has helped develop the jQuery UI and provided a ton of help to me last year trying to get this to work, and boom here is the working copy, you can find Richards blog <a href="http://rdworth.org/blog/" target="_blank">here</a>.</span></p>
<p>The jQuery UI adds classes for different mouse events, for instance:</p>
<ul>
<li><strong>jQuery UI Draggable</strong>
<ul>
<li><strong>.ui-draggable</strong> &#8211; <em>the class it adds you when create the draggable(); object</em></li>
<li><span style="color: #888888;"><span style="color: #000000;"><strong>.ui-draggable</strong></span></span><strong><span style="color: #000000;">-</span></strong><strong><span style="color: #000000;">dragging </span></strong><em>- the class it adds when you are dragging the object around the page</em></li>
</ul>
</li>
<li><strong>jQuery UI Selectable</strong>
<ul>
<li><strong>.ui-selectee<span style="color: #000000;"> </span></strong><strong><span style="color: #000000;">- </span></strong><em>the class it adds when you create the selectable(); object</em></li>
<li><strong>.ui-selectable</strong> &#8211; <em>the class it adds when you select the object</em></li>
<li><strong>.ui-selecting</strong><em> &#8211; the class it adds when you click and start to create the bounding box around the elements you wish to select, once you let go, it becomes <strong>.ui-selectable</strong></em></li>
</ul>
</li>
</ul>
<p>That is the basic structure how how the jQuery UI draggable and selectable generates classes to manipulate change for each action.</p>
<p>I am going to be using console.log(); to report what the code is doing after different steps throughout the page. Make sure you have <a title="Get FireBug!" href="https://addons.mozilla.org/en-US/firefox/addon/1843" target="_blank">Firebug</a> installed if you are on Firefox. If you are unsure what console.log() does view the <a href="http://getfirebug.com/console.html" target="_blank">documentation</a>. Be sure that if you use this technique in a real world example, remove the console.log() functions to decrease page loading time. This neat little function allows us to see what our code is doing, we can call:</p>
<pre lang="javascript">console.log(variable);</pre>
<p>When we open up the page and open Firebug, it will print out what the variable contains, it is a great tool for debugging, keep it handy.</p>
<p>Now that we have the understanding on how it works with different classes, lets start looking at the code that makes it work. I have commented it to make it easier for you to translate on your own time.</p>
<p><strong>The first bits of the code</strong></p>
<pre lang="javascript">// creates the selected variable
// we are going to be storing the selected objects in here
var selected = $([]), offset = {top:0, left:0};
console.log("This is the value of selected when it is created " +selected + "");</pre>
<p>As you can see from above, our first line creates the variable selected and is able to store numerous values because we are setting up an array for this variable. And the offset, resets the top and left values. If you use console.log it will output: <span class="highlight">Object length=0 prevObject=Object jquery=1.2.6</span> notice the length is 0 that is fine we haven&#8217;t selected any items yet.</p>
<pre lang="javascript">// initiate the selectable id to be recognized by UI
$("#selectable1").selectable();</pre>
<p>This part above, calls the selectable to generate the selectable region. <strong>NOTE:</strong> that #selectable is container and is the box not each element we are selecting.</p>
<p>The following part is important because, this is the where we start to hook up selectables with the draggables.</p>
<pre lang="javascript">// declare draggable UI and what we are going to be doing on start
$("#selectable1 div").draggable({
     start: function(ev, ui) {
          $(this).is(".ui-selected") || $(".ui-selected").removeClass("ui-selected");
	  console.log("The value of 'this' currently is: "+this);
          selected = $(".ui-selected").each(function() {
               var el = $(this);
	       el.data("offset", el.offset());
	       $(this).text("Selected and dragging object(s)");
	  });
console.log(selected);
offset = $(this).offset();
},</pre>
<p>The part below, tells the draggable UI to create every element within to have dragging.</p>
<div>
<div id="selectable">
<pre lang="javascript">$("#selectable1 div").draggable({</pre>
<pre lang="javascript">$(this).is(".ui-selected") || $(".ui-selected").removeClass("ui-selected");
console.log("The value of 'this' currently is: "+this);</pre>
<p>This next section above resets the select and drag, by removing the ui-selected class, when we output using console.log, to see the value of this is <span class="highlight">The value of &#8216;this&#8217; currently is: [object HTMLDivElement]</span>.</p>
<pre lang="javascript">selected = $(".ui-selected").each(function() {
     var el = $(this);
     console.log("The value of el is: "+el);
     el.data("offset", el.offset());
     $(this).text("Selected and dragging object(s)");
});</pre>
<p>Now we are finally working with the selected variable we created at the start of this, we are to run through each element with the class of ui-selected. We are going to be storing the value of $(this) in the variable el, to make it easier to call and to work with the offset(); property later on.</p>
<pre lang="javascript">el.data("offset", el.offset());
$(this).text("Selected and dragging object(s)");</pre>
<p>We are going back to out el variable and working with the <a href="http://docs.jquery.com/Internals/jQuery.data">data object</a> and the <a href="http://docs.jquery.com/CSS/offset">offset object</a>. The offset object returns two integer values: <span class="highlight">top and right</span>. The definition of the offset(); from the jQuery documentation is: <span class="highlight">Get the current offset of the first matched element relative to the view port.</span></p>
<p>The other line, changes the text of the elements to let us know that we have selected and are now dragging the objects stored in the variable selected.</p>
<p>Now that we have called offset we want to store it in the variable offset, for each DOM elements selected. The code that follows this part is below:</p>
<pre lang="javascript">console.log("The new value of selected is now "+selected);
offset = $(this).offset();
console.log("The value of top value is "+offset.top+" and the left value is "+offset.left);</pre>
<p>We have another console.log() to print out the selected value and it is storing the DOM element. Next we create the variable offset and store the offset() of the elements, I have printed the top and left values using console.log() above, the output is similar to: <span class="highlight">The value of top value is 207 and the left value is 672</span>.</p>
<p>The next section below is the section of code that handles what is going to go on while we are dragging our selected elements. This part is also very important because we are bringing back the values of offset with the current values of the draggable ui, it stores the ui properties in ui.position.top and ui.position.left. Further down the code we will use the offset values to update the CSS top and left properties of the selected elements.</p>
<pre lang="javascript">drag: function(ev, ui) {
     var dt = ui.position.top - offset.top, dl = ui.position.left - offset.left;
     console.log("The value of dt is "+dt);
     selected.not(this).each(function() {
          var el = $(this), off = el.data("offset");
          el.css({top: off.top + dt, left: off.left + dl});
     });
},</pre>
<p>We are creating the variable dt on the second line there and this value is equal to <span class="highlight">ui.position.top &#8211; offset.top</span> and we are also creating the variable dl that is <span class="highlight">dl = ui.position.left &#8211; offset.left</span>. So we have:</p>
<ul>
<li><strong>var dl</strong> &#8211; <em>working with the x axis or the left coordinates</em></li>
<li><strong>var dt</strong> &#8211; <em>working with the y axis or the top coordinates</em></li>
</ul>
<p>Lets add a console.log to see what these values are before we do the math. Add the following code to see what our variables and math are doing:</p>
<pre lang="javascript">console.log("The value of dt is "+dt+" and is equal to "+ui.position.top+" - "+offset.top);
console.log("The value of dl is "+dl+" and is equal to "+ui.position.left+" - "+offset.left);
console.log("The value of ui.position.top is "+ui.position.top);
console.log("The value of ui.position.left is "+ui.position.left);
console.log("The value of offset.left is "+offset.top);
console.log("The value of offset.left is "+offset.left);</pre>
<p>When you run the code the console.log() outputs the following:</p>
<pre lang="javascript">The value of dt is 37 and is equal to 237 - 200
The value of dl is 152 and is equal to 352 - 200
The value of ui.position.top is 237
The value of ui.position.left is 352
The value of offset.top is 200
The value of offset.left is 200</pre>
<p>Notice what the code is printing out, it is taking the ui.position.top and subtracting the value of offset.top and giving us the difference to equal variable dt. We do this math so we can update the top and left CSS properties in the next section of code, if we didn&#8217;t do this math, we would select and drag our elements and they would move sporadically on the page.</p></div>
</div>
<p>Next we are going to cover the other each function that loops through each of the selected elements expect $(&#8221;this&#8221;):</p>
<pre lang="javascript">// take all the elements that are selected expect $("this"), which is the element being dragged and loop through each.
selected.not(this).each(function() {
     // create the variable for we don't need to keep calling $("this")
     // el = current element we are on
     // off = what position was this element at when it was selected, before drag
     var el = $(this), off = el.data("offset");
     el.css({top: off.top + dt, left: off.left + dl});
});</pre>
<p>So we have the last big piece of code to make this script work. Like I said, you have the each function that runs through each element expect $(&#8221;this&#8221;), then we create two variables:</p>
<ul>
<li><strong>el</strong> &#8211; <em>which is the current element we are on</em></li>
<li><strong>off</strong> &#8211; <em>which is the position of the elements when they were selected, before any type of movement and drag</em></li>
</ul>
<p>The last segment: we are going to be adding or subtracting (we will subtract if the dt or dl is negative). The dl stands for delta left and dt stands for delta top. For instance lets set something up:</p>
<p><span class="highlight">The current element we are on start at the coordinates: 10, 30, now we drag that to: 8, 15. Now lets run the math, the new position of the element is: 2, 15. Say, you drag it again, it runs the loop once again, and the off will be 2, 15 and the new value will be wherever the new coordinates are subtract the total delta from when the drag started until now, not just the last mouse movement.</span></p>
<p>Now that we did the math and we have captured the new value, update it is the css property and plug in the top and left coordinates.</p>
<p>So what did you think of it? Pretty interesting effect when you combine both of those UI elements to create select and drag. Share your thoughts and make sure to bookmark using the button below. Any improvements? Contact me.</p>
<p>Enjoy!</p>


<p>Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/01/22/jquery-timeout-function/' rel='bookmark' title='Permanent Link: jQuery Timeout Function'>jQuery Timeout Function</a> <small>A neat and simple way to creating a jQuery function...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/' rel='bookmark' title='Permanent Link: Using the jQuery UI Slider'>Using the jQuery UI Slider</a> <small>Utilize the jQuery UI Slider to change CSS properties or...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/12/20/jquery-search-and-highlight/' rel='bookmark' title='Permanent Link: jQuery Search And Highlight'>jQuery Search And Highlight</a> <small>Work with the jQuery framework to create a fast Ajax...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Using the jQuery UI Slider</title>
		<link>http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/</link>
		<comments>http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 20:48:22 +0000</pubDate>
		<dc:creator>Ryan Coughlin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.ryancoughlin.com/?p=115</guid>
		<description><![CDATA[Utilize the jQuery UI Slider to change CSS properties or manipulate just about anything you'd like. The UI makes this very easy to comprehend and put to use.


Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/09/12/another-jquery-ui-slider-example/' rel='bookmark' title='Permanent Link: Another jQuery UI Slider Example'>Another jQuery UI Slider Example</a> <small>First post in a very long time. Finally the summer...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/09/hidden-text-seo/' rel='bookmark' title='Permanent Link: Using images With Hidden Text For SEO'>Using images With Hidden Text For SEO</a> <small>Many of us, love to come up with images for...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/' rel='bookmark' title='Permanent Link: Combining Selectables And Draggables Using jQuery UI'>Combining Selectables And Draggables Using jQuery UI</a> <small>Learn how to work with both selectable and draggable with...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Since I started working with jQuery and the UI. I have always wanted to work with the UI Slider.  I always tried playing with it but I never got it execute an operation on slide. I created a slider to change the opacity of my background on my older temp site here at ryancoughlin.com.</p>
<p><span class="highlight"><strong>UPDATE:</strong> Edit changes to the code with available demo below.</span><a href="javascript:;">javascript:;</a></p>
<p><span class="highlight"><strong>UPDATE</strong> (9/16/09): Created a new jQuery UI Slider <a href="http://www.ryancoughlin.com/2009/09/12/another-jquery-ui-slider-example/">example</a>, check it out.<br />
</span></p>
<p><span id="more-115"></span><br />
The man behind helping me with the UI Slider can be found <a href="http://www.keepthewebweird.com/creating-a-nice-slider-with-jquery-ui/" target="_blank">here</a> and his screen cast, which was a huge help.</p>
<p>Check out the jQuery UI Slider <a href="http://www.ryancoughlin.com/demos/slider/" target="_blank">demo</a>. A simple UI Slider example, that will change the opacity of an element on the page, you can implement it to just about anything you want.</p>
<p>Lets get started, if you want to have it handy, check out the <a href="http://docs.jquery.com/UI/Slider" target="_blank">documentation</a> and also make sure to look at the properties and what they control, think of ways that you can work with it to come up with new UI Slider implementations.</p>
<p>One excellent example of the UI slider is at <a href="http://www.komodomedia.com">Komodo Media</a> and below is the slider that he created:<a href="http://www.ryancoughlin.com/wp-content/uploads/2008/11/picture-11.jpg"><img class="aligncenter size-full wp-image-116" title="Komodo - UI Slider Example" src="http://www.ryancoughlin.com/wp-content/uploads/2008/11/picture-11.jpg" alt="" width="266" height="66" /><br />
</a></p>
<p>If you view the site and play around with the slider, you will see the foliage increase and decrease depending on the position of the slider. This led me to wanting to create something similar along these lines. Since day one with jQuery, I saw the slider and always wanted to be able to know how to work with it. But in this article, I can&#8217;t show you how the slider over at Komodo works, sorry maybe Rogie will!</p>
<p>Lets start with all the code below, this controls the slider and the bubble that will let us know the current value of the slider.</p>
<pre title="code" class="javascript">
    $('#slider-bubble').hide();
	$('#slider-bar').slider({
		handle: '#slider-handle',
		min: 0,
		max: 100,
		start: function(e,ui){
		$('#slider-bubble').fadeIn('fast');
		},
		stop: function(e,ui){
		$('#slider-bubble').fadeOut('fast');
		},
		slide: function(e,ui){
		$('#box').css('-moz-opacity', ui.value/100.00).text(ui.value);
		//mypos = $('#slider-handle').position().left + 2;  //grab position of slider dot + 2
		var mypos = $('#slider-bar').slider("value");
		$('#slider-bubble').css('left', mypos).text(ui.value);
		$("#slider-handle").css('left', mypos);

		}
	});
</pre>
<p>Notice we have the following inside the slider function:</p>
<ul>
<li><strong>handle</strong> &#8211; the class name of the click able handle to slide left/right</li>
<li><strong>min</strong> &#8211; sets the minimum value</li>
<li><strong>max</strong> &#8211; sets the maximum value</li>
<li><strong>start</strong> &#8211; execute a function once you move the slider</li>
<li><strong>stop</strong> &#8211; executes a function once you stop moving the slider</li>
<li><strong>slide</strong> &#8211; what should be going on as you slide the handle left/right</li>
</ul>
<p>When we start to drag the the slider we want a bubble to appear to let us know what the current value of the UI Slider is at. We only want it to appear as we start to slide and disappear when we stop. So this line initially hides the bubble on page load:</p>
<pre lang="javascript">$('#slider-bubble').hide();</pre>
<p>The next part is fairly easy, it fades the bubble in on start and fades it out on stop:</p>
<pre lang="javascript">start: function(e,ui){
     $('#slider-bubble').fadeIn('fast');
},
stop: function(e,ui){
     $('#slider-bubble').fadeOut('fast');
},</pre>
<p>The guts of the UI Slider is what is up next to bat, the slide option that controls what is going to be changing as see slide left/right:</p>
<pre title="code" class="javascript">
		slide: function(e,ui){
		$('#box').css('-moz-opacity', ui.value/100.00).text(ui.value);
		//mypos = $('#slider-handle').position().left + 2;  //grab position of slider dot + 2
		var mypos = $('#slider-bar').slider("value");
		$('#slider-bubble').css('left', mypos).text(ui.value);
		$("#slider-handle").css('left', mypos);
		}
</pre>
<p>Once we start to slide, it will update and change the value of the CSS property &#8220;-moz-opacity&#8221; and it will change the opacity of the &#8220;#panels-contents&#8221; element. For the slider, the value is stored in the function parameter &#8220;ui&#8221; so together with &#8220;ui.value&#8221; we can use this to update our opacity.</p>
<p>With this following bit of code the &#8220;.text(ui.value);&#8221; updates the value of that property with the current value of the slider.</p>
<p>The variable &#8220;mypos&#8221; works with the last line of the slide option to the bubble to print out the current value of the slider. Make sure that the bubble element is set to &#8220;position:absolute;&#8221;  The CSS for my slider is below:</p>
<pre title="code" class="css">
#panel-contents{position:relative;height:40px;}
#small-label{ background:url(images/small_label.gif) no-repeat; height:4px; width:17px; overflow:hidden;float:left; }
#large-label{ background:url(images/large_label.gif) no-repeat; height:18px; width:17px; overflow:hidden;float:left; }
#slider-bar{ background:url(images/slider.gif) no-repeat; height:4px; width:100px; position:relative; float:left;}
#slider-handle{ background:url(images/slider_handle.gif) no-repeat; height:12px; width:13px; overflow:hidden;position:absolute;z-index:1;}
#slider-bubble{ background:url(images/callout.gif) no-repeat; height:46px; width:38px; overflow:hidden; position:absolute; top:-50px;padding:8px 0 0 0;text-align:center;font-weight:bold;color:#202020; }
#box{position:absolute; left:40px;background-color:#202020;width:200px;height:200px;}</pre>
<p>Hopefully this will clear up any of your problems or questions when using the jQuery UI Slider.</p>
<p>Easier than you thought?</p>


<p>Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/09/12/another-jquery-ui-slider-example/' rel='bookmark' title='Permanent Link: Another jQuery UI Slider Example'>Another jQuery UI Slider Example</a> <small>First post in a very long time. Finally the summer...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/09/hidden-text-seo/' rel='bookmark' title='Permanent Link: Using images With Hidden Text For SEO'>Using images With Hidden Text For SEO</a> <small>Many of us, love to come up with images for...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/' rel='bookmark' title='Permanent Link: Combining Selectables And Draggables Using jQuery UI'>Combining Selectables And Draggables Using jQuery UI</a> <small>Learn how to work with both selectable and draggable with...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
