Home arrow JavaScript arrow Page 3 - Creating Different Push Buttons with the Yahoo Button Control
JAVASCRIPT

Creating Different Push Buttons with the Yahoo Button Control


This is the third article in a series about the Yahoo Button Control. In it, we will discuss how to create some basic "push" buttons using the YBC, which is part of the Yahoo UI framework.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
December 04, 2007
TABLE OF CONTENTS:
  1. · Creating Different Push Buttons with the Yahoo Button Control
  2. · A review: building radio buttons and checkboxes with the Yahoo! Button Control
  3. · Extending the Use of Control Buttons
  4. · Building push buttons using predefined button control HTML

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Creating Different Push Buttons with the Yahoo Button Control - Extending the Use of Control Buttons
(Page 3 of 4 )

As I explained in the section that you just read, the handy Yahoo! Button Control allows you to easily build different types of buttons. In this case, I’m going to demonstrate how to create one in particular, called “push,” which, as its name suggests, behaves like a conventional web form button. It’s not linked by default to any specified URL, unless this is done by using the respective <a> tag.

Now that I have explained how a “push” button works, please take a look at the signature of the following hands-on example, which shows how to build this kind of widget by using two existing <input type=”button”> tags. The corresponding code sample is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

  <head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-
8859-1" />

<title>Example of "push" Yahoo Button using input
type=button</title>

<!-- Include core + Skin CSS files-->

<link rel="stylesheet" type="text/css"
href="build/button/assets/skins/sam/button.css">

<!-- This file is optional: Menu Stylesheet (required for
creating buttons of type "menu" and "split") -->

<link rel="stylesheet" type="text/css"
href="build/menu/assets/skins/sam/menu.css">

<!-- Include dependencies -->

<script type="text/javascript" src="build/yahoo-dom-event/yahoo-
dom-event.js"></script>

<script type="text/javascript" src="build/element/element-beta-
min.js"></script>

<!-- This file is optional: Menu and Container Core (required for
creating buttons of type "menu" and "split") -->

<script type="text/javascript"
src="build/container/container_core-min.js"></script>

<script type="text/javascript" src="build/menu/menu-
min.js"></script>

<!-- Source file -->

<script type="text/javascript" src="build/button/button-beta-
min.js"></script>

</head>

  <body class="yui-skin-sam">

<input type="button" id="pushbutton1" name="button1" value="Push
Button 1">

<input type="button" id="pushbutton2" name="button2" value="Push
Button 2">

 <script type="text/javascript">

   var sPushButton1 = new YAHOO.widget.Button("pushbutton1");

   var sPushButton2 = new YAHOO.widget.Button("pushbutton2");

</script>

</body>

</html>

As you can see, the above example illustrates how to build a pair of “push” buttons” by using two existing “<input type=”button”> tags and the familiar “YAHOO.widget.Button” class that you saw in previous articles of the series. Not too difficult to grasp, right?

And finally, here’s an additional screen shot that shows more clearly the look and feel of the “push” buttons just created:

All right, at this point I think that you should have a solid background on how to build “push” buttons by using the neat Yahoo! Button Control along with a few simple “<input type=”button”> tags. However, I’d like to expand a bit more on  how to build these widgets. Thus, in the last section of this tutorial I’ll show you yet another practical example, aimed at creating the buttons in question, but this time by using a predefined CSS class bundled with the Yahoo UI library, called “yui-push-button”.

To see how this brand new hands-on example will be developed, please jump ahead and read the next few lines.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials