CNET JS Code Documentation
Script: StickyWin.Ajax
Adds ajax functionality to all the StickyWin classes.
Author: Aaron Newton
The following classes are created
- StickyWin.Ajax - extended form of StickyWin
- StickyWinFx.Ajax - extended form of StickyWinFx
- StickyWinModal.Ajax - extended form of StickyWinModal
- StickyWinFxModal.Ajax - extended form of StickyWinFxModal
Each class here is identical to its extended form with the additional options listed below.
Options
- url - (string) the default url for the instance to hit for its content.
- requestOptions - (object) options passed to the ajax Request; defaults to {method:'get'}.
- wrapWithUi - (boolean) true: wraps the response in StickyWin.ui; false: does not; defaults to false.
- caption - (string) if wrapping with StickyWin.ui, this caption will be used; defaults to an empty string.
- uiOptions - (object) if wrapping with StickyWin.ui, these options will be passed along as the options to StickyWin.ui; defaults to {} (empty object)
- handleResponse - (function) handles the response from the server. By default it will wrap the response html with StickyWin.ui if that option is enabled (which it isn't by default), then calls StickyWin.setContent and then StickyWin.show. This method is meant to be replaced with custom handlers if you want a different behavior (which is why it's an option).
StickyWin.Ajax Method: update
Sends a request for new content.
Syntax
myStickyWinAjax.update(url);
Arguments
- url - (string, optional) the url to request new content from; defaults to the url specified in the options.
Returns
- (object) This instance of StickyWin.Ajax.
Example
var myStickyWin = new StickyWin.Ajax({ url: '/my/html/fragment.html' }); myStickyWin.update(); //retrieves the data from the url
Notes
- you can specify a different url at any time
- data specified in the requestOptions will be sent with each request
- the data is not requested from the server on initialize but instead only when you execute .update
- this file only depends on StickyWin; if you also include StickyWinFx, StickyWinFx.Drag, StickyWinModal they will also be extended with *.Ajax versions.