Last active
August 29, 2015 14:15
-
-
Save maranemil/d0ceaf42822ac431d38b to your computer and use it in GitHub Desktop.
SugarCRM 7 How to load the same javascript function in more extended views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example usage common function defined in sidecar: | |
------------------- | |
// "custom-record": {"controller": | |
({ | |
// Record View (base) | |
extendsFrom: 'RecordView', | |
initialize: function (options) { | |
//this.plugins = _.union(this.plugins, ['MyAmazingFunctionFour']); // Call function through plugins | |
//app.MyAmazingFunction() // Call function through app | |
//SUGAR.util.MyAmazingFunctionTwo(); // Call function through SUGAR.util | |
} | |
}) | |
----------------------- | |
Example Function defined in sidecar: | |
// compiled from custom/modules/Contacts/my_special_script.js | |
(function () { | |
SUGAR.util = SUGAR.util || {}; | |
SUGAR.util.MyAmazingFunctionTwo = function () { | |
alert("456") | |
} | |
})(); | |
(function (app) { | |
app.events.on('app:init', function () { | |
app.MyAmazingFunction = function () { | |
alert("123") | |
}; | |
}); | |
})(SUGAR.App); | |
(function (app) { | |
app.events.on('app:init', function () { | |
app.plugins.register('MyAmazingFunctionFour', ['layout', 'view'], { | |
onAttach: function () { // onAttach/onDetach/handleErrorEvent | |
this.on("init", function () { | |
alert(789); | |
//app.MyAmazingFunction(); | |
}); | |
} | |
}); | |
}); | |
})(SUGAR.App); | |
--------------------------- | |
Example JSGroupings Include | |
// custom/Extension/application/Ext/JSGroupings/custom_js_groupings.php | |
$js_groupings[] = $sugar_grp_sidecar = array_merge($sugar_grp_sidecar, | |
array( | |
'custom/modules/Contacts/my_special_script.js' => 'include/javascript/sugar_sidecar.min.js', | |
) | |
); | |
------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment