Skip to content

ElementData

Andrey Kharanenka edited this page Aug 30, 2017 · 1 revision

ElementData is abstract class for components. Return object of ElementItem class for model.

Method list

get($iElementID)

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%}

onGetData()/onGetJSONData()

Return array/json string item data. Uses in ajax requests.

$.request('ElementData::onGetData', {
    data: {'element_id': 1},
    success: function(responce) {
      console.log(responce);
    }
});

onAjaxRequest()

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%}
Clone this wiki locally