Difference between revisions of "Javascript API"
(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...") |
|||
Line 26: | Line 26: | ||
'''cj Objects''' <br /> | '''cj Objects''' <br /> | ||
− | '''cj.frame (requires admin framework)''' <br /> | + | '''1. cj.frame (requires admin framework)''' <br /> |
− | The remote method uses ajax to execute server add-on methods. <br /> | + | : The remote method uses ajax to execute server add-on methods. <br /> |
− | '''cj.frame.submitForm( remoteMethodName, frameHtmlId, formHtmlId)''' <br /> | + | : '''cj.frame.submitForm( remoteMethodName, frameHtmlId, formHtmlId)''' <br /> |
− | : '''Example''' <br /> | + | :: '''Example''' <br /> |
− | : cj.frame.submitForm('myAccountFrameHandler','myAccountFrame','FormToSubmitId'); <br /> | + | :: cj.frame.submitForm('myAccountFrameHandler','myAccountFrame','FormToSubmitId'); <br /> |
− | : '''Arguments''' <br /> | + | :: '''Arguments''' <br /> |
− | : remoteMethodName: string - the name of the addon to call | + | :: remoteMethodName: string - the name of the addon to call |
− | : frameHtmlId: string - html Id of frame that will receive the html results from the addon | + | :: 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 | + | :: formHtmlId: string - the Html Id of the form that will be submitted to the remoteMethod |
− | '''cj.frame.update( remoteMethodName, frameHtmlId, queryString)''' <br /> | + | : '''cj.frame.update( remoteMethodName, frameHtmlId, queryString)''' <br /> |
− | : '''Example''' <br /> | + | :: '''Example''' <br /> |
− | : cj.frame.update('myAccountFrameHandler','myAccountFrame','formId=10'); <br /> | + | :: cj.frame.update('myAccountFrameHandler','myAccountFrame','formId=10'); <br /> |
− | : '''Arguments''' <br /> | + | :: '''Arguments''' <br /> |
− | : remoteMethodName: string - the name of the addon to call | + | :: remoteMethodName: string - the name of the addon to call |
− | : frameHtmlId: string - html Id of frame that will receive the html results from the addon | + | :: 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 | + | :: queryString: string - Anything else to be passed to the remoteMethod |
− | + | '''2. cj.remote''' <br /> | |
cj.xml | cj.xml | ||
cj.ajax | cj.ajax | ||
cj.admin | cj.admin |
Revision as of 14:35, 2 July 2015
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
1. cj.frame (requires admin framework)
- The remote method uses ajax to execute server add-on methods.
- cj.frame.submitForm( remoteMethodName, frameHtmlId, formHtmlId)
- Example
- Example
- cj.frame.submitForm('myAccountFrameHandler','myAccountFrame','FormToSubmitId');
- cj.frame.submitForm('myAccountFrameHandler','myAccountFrame','FormToSubmitId');
- Arguments
- 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
- Example
- cj.frame.update('myAccountFrameHandler','myAccountFrame','formId=10');
- cj.frame.update('myAccountFrameHandler','myAccountFrame','formId=10');
- Arguments
- 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
2. cj.remote
cj.xml cj.ajax cj.admin