jxt:
"). Separate work on JXT was made possible thanks to the unspoken standard defined by modern Java Script libraries that provide a separate argument (“configuration” of the object) passed to the constructor to initialize the component, which is then translated (executed) to a given target element (usually in a div
). Thus, the syntax will be the same for the widgets of both libraries. The tag looks like this:
- < jxt: widget type = "libraryName" name = "widgetName" >
- < jxt: target >
- < div > </ div >
- </ jxt: target >
- </ jxt: widget >
<jxt:cfg>
tags. <jxt:cfg>
tag is a “key” (key) inside an object, it has a name, a value, and may contain infinite “subkeys”, just like in JSON, but instead of switching this object to a constructor, in JXT you just put <jxt: cfg> into <jxt: widget>:
- < jxt: widget type = "libraryName" name = "widgetName" >
- < jxt: cfg name = "param1" value = "value1" type = "string" > </ jxt: cfg >
- < jxt: cfg name = "param2" type = "object" >
- < jxt: cfg name = "prop1" value = "value1" type = "string" > </ jxt: cfg >
- < jxt: cfg name = "prop2" value = "value2" type = "string" > </ jxt: cfg >
- </ jxt: config >
- < jxt: target >
- < div > </ div >
- </ jxt: target >
- </ jxt: widget >
- {
- id: "myForm",
- url: "submit.php",
- items: [
- {
- label: "name",
- allowBlank: false,
- fieldLabel: "First name"
- },
- {
- label: "Last name",
- allowBlank: false,
- fieldLabel: "last"
- },
- new Ext.form.TimeField ({
- fieldLabel: "Time",
- name: "time",
- minValue: "8:00 am",
- maxValue: "6:00 pm"
- })
- ],
- buttons: [
- {
- label: "save",
- click: function () {
- alert ("save!");
- }
- },
- {
- label: "reset",
- click: function () {
- alert ("reset!");
- }
- }
- ]
- }
- < jxt: cfg type = "string" name = "id" value = "myForm" > </ jxt: cfg >
- < jxt: cfg type = "string" name = "url" value = "submit.php" > </ jxt: cfg >
- < jxt: cfg type = "array" name = "items" >
- < jxt: cfg type = "object" >
- < jxt: cfg type = "string" name = "label" value = "name" > </ jxt: cfg >
- < jxt: cfg type = "boolean" name = "allowBlank" value = "false" > </ jxt: cfg >
- < jxt: cfg type = "string" name = "fieldLabel" value = "First name" > </ jxt: cfg >
- </ jxt: cfg >
- < jxt: cfg type = "object" >
- < jxt: cfg type = "string" name = "label" value = "last" > </ jxt: cfg >
- < jxt: cfg type = "boolean" name = "allowBlank" value = "false" > </ jxt: cfg >
- < jxt: cfg type = "string" name = "fieldLabel" value = "Last name" > </ jxt: cfg >
- </ jxt: cfg >
- < jxt: cfg type = "object" jsclass = "Ext.form.TimeField" >
- < jxt: cfg type = "string" name = "fieldLabel" value = "Time" > </ jxt: cfg >
- < jxt: cfg type = "string" name = "name" value = "time" > </ jxt: cfg >
- < jxt: cfg type = "string" name = "minValue" value = "8:00 am" > </ jxt: cfg >
- < jxt: cfg type = "string" name = "minValue" value = "6:00 pm" > </ jxt: cfg >
- </ jxt: cfg >
- </ jxt: cfg >
- < jxt: cfg type = "array" name = "buttons" >
- < jxt: cfg type = "object" >
- < jxt: cfg type = "string" name = "label" value = "save" > </ jxt: cfg >
- < jxt: cfg type = "function" name = "click" value = "alert ('save!')" > </ jxt: cfg >
- </ jxt: cfg >
- < jxt: cfg type = "object" >
- < jxt: cfg type = "string" name = "label" value = "reset" > </ jxt: cfg >
- < jxt: cfg type = "boolean" name = "allowBlank" value = "alert ('reset!')" > </ jxt: cfg >
- </ jxt: cfg >
- </ jxt: cfg >
<jxt:widget>
tag and its subtags. JXT also offers its own tags and properties that can be combined with each other to achieve the desired result. At the moment there are not many of them, but their number will increase in subsequent releases. However, you can already use <jxt:if>
to express conditions, <jxt:datetime>
to print a formatted date, and <jxt:loop>
to duplicate html nodes. The latter is simply wonderfully combined with such a widget as “carousel” for dynamic output of the Nth number of img tags (where N is the number of attribute “steps”). In fact, it even has a special record that allows you to specify the number of iterator cycles, here is an example:
- < jxt: loop steps = "10" >
- < img src = "img / demo_pic_ {loop: step} .jpg" alt = "pic {loop: step}" />
- </ jxt: loop >
<jxt:widget>
declarations. If you are interested (as I hope), you can find out more about JXT here: http://www.jxtproject.comSource: https://habr.com/ru/post/72503/
All Articles