Function Namespace Pot.Signal.attachBefore
Defined in: <pot.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Pot.Signal.attachBefore(object, signalName, callback, (useCapture), (once))
Attaches a signal to a slot on before,
and return a handler object as a unique identifier that
can be used to detach that signal.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
Pot.Signal.attachBefore.once(object, signalName, callback, (useCapture))
Similar to attach*(),
but detaches the signal handler automatically once it has fired.
|
Function Namespace Detail
Pot.Signal.attachBefore(object, signalName, callback, (useCapture), (once))
Attaches a signal to a slot on before,
and return a handler object as a unique identifier that
can be used to detach that signal.
// Set the event of pressing the Save button. attach('#saveData', 'click', function() { // Saving function. saveData(document.getElementById('inputText').value); // Function to send a message to user that the data saved. showSaveData('Saved!'); }); // Add the callback function for // move the focus after click the element. attachAfter('#saveData', 'click', function() { document.getElementById('inputText').focus(); }); // To configure the logging before calling it. attachBefore('#saveData', 'click', function() { MyLogger.log('Save inputText'); });
- Parameters:
- {Object|Function|String} object
- The object that be target of the signal. If passed in a string then will be a HTML element by document.getElementById.
- {String|Array} signalName
- `signalName` is a string that represents a signal name. If `object` is a DOM object then it can be specify one of the 'onxxx' native events. That case 'on' prefix is optionally.
- {Function} callback
- An action to take when the signal is triggered.
- {Boolean} (useCapture)
- (Optional) `useCapture` will passed its 3rd argument to addEventListener if environment is available it on DOM.
- {Boolean} (once)
- (Optional) Only internal usage.
- Returns:
- {Object|Array} Return an instance of Pot.Signal.Handler object as a unique identifier that can be used to detach that signal.
Method Detail
<static>
{Function}
Pot.Signal.attachBefore.once(object, signalName, callback, (useCapture))
Similar to attach*(),
but detaches the signal handler automatically once it has fired.
attachBefore.once(document.body, 'click', function() { alert('This message will show only once.'); });
- Parameters:
- {Object|Function|String} object
- The object that be target of the signal. If passed in a string then will be a HTML element by document.getElementById.
- {String} signalName
- `signalName` is a string that represents a signal name. If `object` is a DOM object then it can be specify one of the 'onxxx' native events. That case 'on' prefix is optionally.
- {Function} callback
- An action to take when the signal is triggered.
- {Boolean} (useCapture)
- (Optional) `useCapture` will passed its 3rd argument to addEventListener if environment is available it on DOM.
- Returns:
- {Object} Return an instance of Pot.Signal.Handler object as a unique identifier that can be used to detach that signal.