Javascript API

From Contensive Wiki
Revision as of 14:33, 2 July 2015 by Admin (Talk | contribs) (Created page with "The Javascript API contains a programming interface to simplify the interaction between the server and the browser. You reference the API with the cj object in javascript. <br...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Javascript API contains a programming interface to simplify the interaction between the server and the browser. You reference the API with the cj object in javascript.

A simple example is a text box that saves it's data as it is typed. Create a new add-on, and add a text box. Add javascript to onChange or onKeyUp of the text box to call the cj.ajax.data() method to save the content of the text box into a field in a record of a table.

Drop this add-on on any page, and when it is rendered, the data will automatically save.

Alternately, you can write a remote method add-on that accepts data from the query string and saves it how you wish. Your client-side code could then call the cj.ajax.addon() method which executes your server-side code and performs the function.

cj Methods

  • cj.setSpinner()
  • cj.encodeHTML()
  • cj.invisible()
  • cj.visible()
  • cj.hide()
  • cj.show()
  • cj.setFrameHeight()
  • cj.encodeTextAreaKey()
  • cj.addHeadScriptLink()
  • cj.addHeadStyle()
  • cj.addHeadStyleLink()
  • cj.addHeadScriptCode()
  • cj.addLoadEvent()
  • cj.addListener()

cj Objects

cj.frame (requires admin framework)

The remote method uses ajax to execute server add-on methods.

cj.frame.submitForm( remoteMethodName, frameHtmlId, formHtmlId)

Example
cj.frame.submitForm('myAccountFrameHandler','myAccountFrame','FormToSubmitId');
Arguments
remoteMethodName: string - the name of the addon to call
frameHtmlId: string - html Id of frame that will receive the html results from the addon
formHtmlId: string - the Html Id of the form that will be submitted to the remoteMethod

cj.frame.update( remoteMethodName, frameHtmlId, queryString)

Example
cj.frame.update('myAccountFrameHandler','myAccountFrame','formId=10');
Arguments
remoteMethodName: string - the name of the addon to call
frameHtmlId: string - html Id of frame that will receive the html results from the addon
queryString: string - Anything else to be passed to the remoteMethod


   cj.remote
   cj.xml
   cj.ajax
   cj.admin