My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
API  
API demonstrations and code examples
Phase-Implementation, Featured
Updated Feb 4, 2010 by Crag...@gmail.com

Scripting API

The Simpletip comes with a great scripting API for users. A lot of effort has been made to make sure you have the necessary functionality to enrich the library with as little effort as possible. Once you've setup your simpletip on your element(s) the API can be accessed via the simpletip() call. An example of this is below:

// Create your tooltips 
$('JQUERY SELECTOR').simpletip(); 

// Access the API of a previously initatied simpletip 
var api = $('JQUERY SELECTOR').eq(0).simpletip(); 

// Perform a simple API call to update tooltip contents 
api.update('New tooltip content!');

Here's a list of all API methods available to you in the library:

Method Arguments Return value Description
getVersion() [x, x, x] Returns the version number of the Simpletip library currently in use.
getParent() Object Returns the element which the tooltip is associated with e.g. the element on which the simpletip() method was called.
getTooltip() Object Returns the tooltip element.
getPos() [top, left] Returns the absolute current position of the tooltip element.
setPos() posX, posY Simpletip Sets position of tooltip to absolute arguments posX and posY if supplied as integers, or relative to parent element if supplied as strings. A mixture of both strings and integers can also be used.
show() Simpletip Displays the tooltip element.
hide() Simpletip Hides the tooltip element.
update() content Simpletip Updates the contents of the tooltip element with the supplied argument, usually a string or integer.
load() url, data Simpletip Updates the contents of the tooltip element with the contents of a remote file url using AJAX. Use the data array to pass POST data on the AJAX call.

Callback functions

The Simpletip library provides several key callback functions as part of it's API, allowing you to extend the functionality of the library with custom methods. Below is an example utilising the onShow method to change the content an element:

$("JQUERY SELECTOR").simpletip({ 
   // onShow method - change content of parent element 
   onShow: function(){ 
      this.getParent().text('My content changes when my tooltip appears!') 
   } 
   // Configuration properties 
   content: 'My Simpletip' 
});

Checkout the demos page for more examples.


Sign in to add a comment
Powered by Google Project Hosting