Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
a4fd252a
Commit
a4fd252a
authored
Feb 29, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Elaborate on the right way to call super methods in plugins.
parent
c0c4cd92
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
docs/source/development.rst
docs/source/development.rst
+18
-7
No files found.
docs/source/development.rst
View file @
a4fd252a
...
...
@@ -888,27 +888,38 @@ An example plugin
// For example, the inner protected *converse* object has a
// method "onConnected". You can override that method as follows:
onConnected: function () {
// Override the onConnected method in converse.js
// You have access to the protected converse object via the
// _super attribute.
var converse = this._super.converse;
// Overrides the onConnected method in converse.js
// Top-level functions in "overrides" are bound to the
// inner "converse" object.
var converse = this;
// Your custom code comes here.
// ...
// You can access the original function being overridden
// vai the _super attribute.
this._super.onConnected();
// via the _super attribute.
// Make sure to pass on the arguments supplied to this
// function and also to apply the proper "this" object.
this._super.onConnected.apply(this, arguments);
},
XMPPStatus: {
// Override converse.js's XMPPStatus Backbone model so that we can override the
// function that sends out the presence stanza.
sendPresence: function (type, status_message, jid) {
// The "converse" object is available via the _super
// attribute.
var converse = this._super.converse;
// Custom code can come here
// ...
this._super.sendPresence(type, status_message, jid);
// You can call the original overridden method, by
// accessing it via the _super attribute.
// When calling it, you need to apply the proper
// context as reference by the "this" variable.
this._super.sendPresence.apply(this, arguments);
}
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment