Zrinity is the leader in enterprise-class email marketing
management solutions and content management solutions for marketing professionals and developers worldwide.
Knowledge BaseUsing the ActivEdit API to change behavior
Create custom libraries for specific applications
The ActivEdit API is incredibly powerful! It gives you the power to reuse the same object and also change it's behavior for a specific application or instance. Java developers will be very comfortable with the API, as it allows them to extend the ActivEdit library much like they would extend a Java library.
To invoke the API, you only need to include a single API function in your form page. The example shown below uses the aeapi_local_onLoad() API function. When it exists in a page with one or more instances of ActivEdit, everything inside it will be executed when an ActivEdit instance is created.
You can place the aeapi_local_onLoad() function in a JavaScript template and easily include it in a form page with <script language="JavaScript" src="/pathToLibrary/aLibrary.js"></script>. This is a great way to encapsulate libraries and behaviors to make them reuseable.
This example shows how you can extend the existing onChange handler for an ActivEdit instance. You'll often need the source to extend the library, but will use it only as a reference. By using the API instead of directly editing the editjs library, your code will be portable to different problem spaces, future updates and upgrades.
<script language="JavaScript">
//Runs when an ActivEdit instance loads function aeapi_local_onLoad(aeObject, fieldname) {
//override ae_ondisplaychange ae_ondisplaychange = function(num) { //the old contents set_tbstates(num);
//add something here
/* Note that although the API function gets an object reference for each instance loaded, ae_ondisplaychange receives only an instance number. We'll use that instance number (num) to reference our instance with array syntax.*/
if(aeObjects{num].DOM.body.innerHTML.length > 500) { alert("Whoa Nelli! You planning on writing a book?"); } } }