Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Returning values from our plugin


A key part of creating a plugin is – what information can we get back from the plugin? Sometimes we can't get information out, but that may just be a limitation of what we're trying to achieve with the plugin. In our case, we should be able to get the content out. Let's take a look at how we can achieve this with our quicktip plugin.

Before delving into the code, we'll take a look at what we're creating:

  1. We need to start somewhere, and so there is no better place than the markup. In a copy of tooltipv2.html, go ahead and add the following highlighted code before closing the <div> tag:

      <input type="submit" id="getValue" value="Get text from first tooltip" />
      <div id="dialog" title="Basic dialog">
      </div>
  2. In a copy of tooltipv2.js, we need to expose the data- tags that we're implementing in the markup. Go ahead and add the configuration option for tiptag, as indicated next:

    $(document).ready(function() {
      $('#img-list li a.tooltips...