Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
BLOG: Extensions in LinkedIn's JavaScript API
<script type="text/javascript" src="">
api_key: api_key_123456
extensions: MyExtension@
IN.Event.on(IN, "frameworkLoaded", function() {
// modifies IN.API.base to add a method that converts results to JSON
var IN_APIS_BASE = Sslac.definitionOf("IN.APIs.Base"),
construct = IN_APIS_BASE.getConstructor(),
handleSuccess = IN_APIS_BASE.getMethod("handleSuccessResults");
.Constructor(function() {
this.handlers.json = [];
.Method("json", function() {
this.addHandler(this.handlers.json, [].slice.apply(arguments));
return this;
.Method("handleSuccessResults", function(results) {
// run and clear the json handlers
this.runHandler(this.handlers.json, JSON.stringify(results));
// run original method
return handleSuccess.apply(this, arguments);
IN.ENV.js.extensions.MyExtension.loaded = true;
IN.Event.on(IN, "frameworkLoaded", function() {
// body of extension goes here
IN.ENV.js.extensions.MyExtension.loaded = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment