The back-office of Novius OS is one “big HTML page”. Actions performed in one tab can affect other tabs (ex: adding, modifying or deleting an item).
An event system has been established to enable the various interface elements to communicate with each other.
$container.nosAjax()
),
which are then dispatched to all interface elements via dispatchers.Dispatched events are executed immediately on the current active tab or popup (the one which has focus). For other tabs (or popups), they are executed only when the tab or popup becomes active / focused.
Event
¶Event.
name
¶string
Model
, the name is the Model name, including its PHP namespace.Event.
id
¶int
or [int]
Model
, ID(s) of the item to which they relate.Event.
action
¶string
insert
, update
or delete
.Event.
context
¶string
or [string]
$container.
nosListenEvent
(event, callback[, caller])¶For the callback function to be triggered, listened and triggered events should not match exactly. The listened event can just match one property of the triggered event.
Arguments: |
|
---|
// Listen all events with name 'Nos\Model_Page'
$(domContext).nosListenEvent({
name: 'Nos\Model_Page'
}, function(event) {
// ...
}, 'caller');
// Listen all events with the 'Nos\Model_Page' name and 'insert' or 'delete' actions
$(domContext).nosListenEvent({
name: 'Nos\Model_Page',
action: ['insert', 'delete']
},
function(event) {
// ...
});
// Listen all events with the 'Nos\Model_Page' name and 'insert' or 'delete' actions,
// or events with the 'Nos\Model_Page' name and the 'main::en_GB' context
$(domContext).nosListenEvent([
{
name: 'Nos\Model_Page',
action: ['insert', 'delete']
},
{
name; 'Nos\Model_Page',
context; 'main::en_GB'
}
], function(event) {
// ...
});
$container.
nosUnlistenEvent
(caller)¶Stop listening events for a specific caller. See caller param of nosListenEvent
.
Arguments: |
|
---|
$(domContext).nosUnlistenEvent('caller');
$.
nosDispatchEvent
(event)¶Dispatches an event to all available dispatchers.
Arguments: |
|
---|
// Dispatch event, page with ID 4 has been create with 'main::en_GB' context
$.nosDispatchEvent({
name: 'Nos\Model_Page',
action: 'insert',
id: 4,
context: 'main::en_GB',
});