-
Notifications
You must be signed in to change notification settings - Fork 20
ElementData
Andrey Kharanenka edited this page Aug 30, 2017
·
1 revision
ElementData is abstract class for components. Return object of ElementItem class for model.
Return object of ElementItem class with ID = $iElementID.
{% set obItem = ElementData.get(1) %}
{% if obItem.isNotEmpty() %}
<div data-id="{{ obItem.id }}">
<h1>{{ obItem.name }}</h1>
<div>{{ obItem.description|raw }}</div>
</div>
{% endif%}
Return array/json string item data. Uses in ajax requests.
$.request('ElementData::onGetData', {
data: {'element_id': 1},
success: function(responce) {
console.log(responce);
}
});
Empty method for ajax request.
$.request('ElementData::onAjaxRequest', {
data: {'element_id': 1},
update: {'my_partial': '.my_class'}
});
{# my_partial.htm #}
{% set obItem = ElementData.get(input('element_id')) %}
{% if obItem.isNotEmpty() %}
<div data-id="{{ obItem.id }}">
<h1>{{ obItem.name }}</h1>
<div>{{ obItem.description|raw }}</div>
</div>
{% endif%}