Usewidget (element)

From JRapid

Jump to: navigation, search

usewidget is an element, child of config.



The usewidget element is used for declaring widgets in a project.

No property can specify a value for its widget attribute if this is not declared as the name for an existing usewidget element.

Widgets may be implemented through the use of a jQuery plugin, in which case the jquery and jqueryoptions may be used to ease the declaration. The jquery attribute holds the name of the function used to initialize the jQuery plugin on an HTML element. The jqueryoptionsattribute holds initialization options if needed.


      name = NAME
      jquery = JQUERY_NAME
      jqueryoptions = JQUERY_OPTIONS



The well known jQuery UI datepicker widget is used by default by every JRapid project. That's why the config element includes the proper usewidget element when starting a JRapid project from scratch.

        <usestylesheet location="../jrapid-runtime/css/ui-lightness/jquery-ui-1.8rc2.custom.css"/>
        <usescript location="../jrapid-runtime/jquery-1.4.2.min.js"/>
        <usescript location="../jrapid-runtime/jquery-ui-1.8rc2.custom.min.js"/>
        <usewidget jquery="datepicker" jqueryoptions="{changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy'}" name="jdatepicker">
            <usescript location="../jrapid-runtime/extras/widget-jdatepicker/js/jquery.ui.datepicker.min.js"/>

The name given to this widget in the JRapid project is jdatepicker and this will be the value to use in the widget attribute of any property that should make use of it.

The name of the method to be called on the HTML element that should hold this widget is datepicker, as specified in the jQuery UI datepicker documentation.

The jqueryoptions attribute in this example is used to set initialization parameters supported by the jQuery UI Datepicker such as date format.

See also

Personal tools