Base widget class for all PAX widgets
Mikkel Bergmann, http://www.pointful.com
| pax. | Base widget class for all PAX widgets |
| Properties | |
| pax. | Unique identifiers counter for widgets |
| Functions | |
| pax. | Initialises a PAX widget |
| bindElements. | This will bind functions, by using the class names that you specify in the pax.widget.init method, through the bindElements object |
| bindElements.id | This will bind functions, by using the element ids that you specify in the pax.widget.init method, through the bindElements object |
| bindElements. | This will bind functions, by using the element id + _target id that you specify in the pax.widget.init method, through the bindElements object. |
| pax. | This creates an ajax based widget based on the widget object. |
| pax. | This creates an ajax based widget, using pax.widget.init as a base widget object. |
pax.widget.init = function( args )
Initialises a PAX widget
| args | Object with widget functionality |
Object with model and various widget function.
<div style='border: 1px solid grey' id='widget_output'></div>
[:.
var myWidget = pax.widget.init( {
model: {
text: 'Hello, this is my first widget!'
},
template: 'Your text is: "[:= text :]".',
target: pax.$('widget_output')
} );
myWidget.render();
:]This would show the template rendered in the target. See pax.template for template details.
This will bind functions, by using the class names that you specify in the pax.widget.init method, through the bindElements object
| args | Object with CSS class name as key, and functions as values |
Not applicable
This is an internal method to the pax.widget system, and can only be accessed through the init methods.
pax.widget.init(
target: target,
model: model,
template: args.template,
bindElements: {
classNames: {
'backButtonCSSClass': {
click: function( e ) {
if( model.offset > 0 ) {
model.offset -= 1;
model.widget.render();
}
}
}
}
}
);This example shows how to access the classNames binding through the pax.widget.init method. ‘backButtonCSSClass’ is the CSS class on the button you want to attach the events to, in this case we have a ‘click’ event to attach to the button.
This will bind functions, by using the element ids that you specify in the pax.widget.init method, through the bindElements object
| args | Object with element ids as keys, and functions as values |
Not applicable
This is an internal method to the pax.widget system, and can only be accessed through the init methods.
pax.widget.init(
target: target,
model: model,
template: args.template,
bindElements: {
id: {
'myButtonID': {
click: function( e ) {
alert('You clicked on the button!');
}
}
}
}
);This example shows how to access the id binding through the pax.widget.init method. ‘myButtonID’ is the element ID of the button you want to attach the events to, in this case we have a ‘click’ event to attach to the button.
This will bind functions, by using the element id + _target id that you specify in the pax.widget.init method, through the bindElements object. The purpose of this method is to semi-automatically provide a way to have unique elements for instances of the same widget.
| args | Object with element id as keys, and functions as values |
Not applicable
This is an internal method to the pax.widget system, and can only be accessed through the init methods.
// Assume that you have a widget where you have defined a button in the template like so:
// <input type='button' id='forward_[:= model.target.id :]' value = 'Forward'/>
pax.widget.init(
target: target,
model: model,
template: args.template,
bindElements: {
internal: {
'forward': {
click: function( e ) {
alert('You clicked on the forward button!');
}
}
}
}
);This example shows how to access the internal binding through the pax.widget.init method. The ‘forward’ key referes to an element that is defined as “forward_” + model.target.id
pax.widget.ajax.init = function( url, args )
This creates an ajax based widget, using pax.widget.init as a base widget object. ie: it adds an ajax controller, and a server request method.
| args | Object with widget functionality |
Object with model and various widget function.
<div style='border: 1px solid grey' id='ajax_widget_output'></div>
[:.
pax.widget.ajax.init( '../examples/widget_introduction_example3.txt', {
target: pax.$('ajax_widget_output')
} ).serverRequest();
:]This would show the template rendered in the target. See pax.template for template details. Also, be sure to read the widget introduction article!
Initialises a PAX widget
pax.widget.init = function( args )
This creates an ajax based widget, using pax.widget.init as a base widget object.
pax.widget.ajax.init = function( url, args )