Skip to content
Darsain edited this page Jan 6, 2013 · 14 revisions

Calling with jQuery

$('#frame').sly( [ options [, callbackMap ] ] );

[ options ]

Object with sly options. All options are detailed in the Options Wiki page.

[ callbackMap ]

Object with functions that should be bound to callbacks before anything happens. Example:

$('#frame').sly(options, {
	load: function (position, $items, relatives) {},
	move: [
		function (position, $items, relatives) {},
		function (position, $items, relatives) {}
	]
});

This example will bind one function to load event, and two functions to move event.

To see all available events and arguments they receive, head over to Callbacks & DOM Events documentation.

Calling directly Sly class

When you want a complete control over Sly, and have direct access to all methods, you can create and save a new Sly instance yourself.

var sly = new Sly(frame, options, callbackMap);

New instance has to be than initiated. That is to give you time to bind callbacks before anything happens.

sly.init();

The .init() method returns the very same instance it is called on, so if you are binding callbacks via a callbackMap argument, or not binding callbacks at all, you can initiate the instance right after the new Sly call. The sly variable will be the same.

var sly = new Sly(frame, options, callbackMap).init();

Now you can use all methods directly on this instance.

sly.activate(1); // Activates 2nd element
sly.reload();    // Reload Sly

frame

Argument can be a raw or a jQuery wrapped DOM element. Examples:

var sly = new Sly(document.getElementById('frame')); // DOM element
var sly = new Sly(jQuery('#frame'));                 // jQuery object

API documentation

Clone this wiki locally