Answerspace JS Events
Global Variables
BICv2 (MyAnswers)
MyAnswers
This is the primary global object for Answerspace manipulation. Use console.log
to examine it's available properties.
Key properties
Property | Type | Usage |
---|---|---|
activityIndicator | DOM reference | Used to show or hide the loading image. |
getGeoLocation() | Function | Attempt to retrieve GPS data from the device. |
goToDefaultScreen() | Function | Navigates to the A/S default screen |
runningTasks | Property | Counter indicating how many background tasks are running. |
store | Object | Used to set/get Mojo's (see below). |
loginAccount | Object | List of login info from the Users Session. Only set after login. |
siteVars
Contains the Answerspace configuration data. config
, forms
, map
and mojos
can all be interrogated for further information.
Property | Type | Usage |
---|---|---|
siteVars | Object | Contains all answerSpace object details |
siteVars.id | Property | The answerSpace Id |
siteVars.answerSpace | Property | The answerSpace name |
siteVars.serverDomain | Property | The answerSpace domain |
siteVars.serverAppBranch | Property | The answerSpace application branch |
siteVars.serverAppVersion | Property | The answerSpace application version |
deviceVars
Contains information about the client device.
_Blink & _SERVER
Server-side variables.
BIC-JQM (BMP.BIC3)
BMP.BIC3
This is the primary global object for Answerspace manipulation. Use console.log
to examine it's available properties.
Key properties
Property | Type | Usage |
---|---|---|
BMP.BIC.currentInteraction() | Function | Returns the current interaction |
BMP.BIC3.forms.get('myForm') | Function | Returns the forms object called "myForm" |
siteVars
Contains the Answerspace configuration data. config
, forms
, map
and mojos
can all be interrogated for further information.
Property | Type | Usage |
---|---|---|
BMP.BIC3.siteVars | Object | Contains all answerSpace object details |
MP.BIC3.siteVars.answerSpaceId | Property | The answerSpace Id |
MP.BIC3.siteVars.answerSpace | Property | The answerSpace name |
Events
Event | Trigger |
---|---|
viewShow | Answerspace View transition completed, but not yet ready. |
viewReady | Answerspace View is configured and ready. |
$(document).on('viewShow', function() { // this = the .view element /* TODO: insert code to run after a view transition is completed */ }); $(document).on('viewReady', function() { // this = the .view element /* TODO: insert code to run after a view has been enhanced with Stars, Forms, Maps, etc */ });
Navigation
Persistance Storage
BICv2 (MyAnswers.store)
MyAnswers.store
object provides some key methods for interacting with the Blink Storage layer. Using the Chrome Resources
tab will allow you view the contents of your local storage.
MyAnswers.store.set ( key, value )
// simple usage - store and forgetMyAnswers.store.set('fruit', 'apples'); // store, and then do something once the save operation is completed. MyAnswers.store.set('meat', 'kangaroo').done(function () { console.log('Done!'); });
MyAnswers.store.get ( key )
1MyAnswers.store.get('fruit').done(function () { console.log('Done!'); });
MyAnswers.pendingStore.set ( key, value )
MyAnswers.pendingStore.get ( key )
MyAnswers.pendingStore.remove ( key )
BIC-JQM
BIC-JQM uses reliable persistent storage collections.
For more information see BIC-JQM persistent storage for more details.
BMP.BIC.hasStorage()
require(['bic'], function (bic) { // 1. bic.collections().then(function () { // 2. if (bic.hasStorage()) { // 3. // TODO: do something with a persistent collection // e.g. `bic.interactions`, `bic.pending`, etc } }); });
BIC-JQM (BMP.BIC3.pending)
See BIC-jQM: Pending Queue for more details
$.when(BMP.BIC.pending.initialize).then(function () { /* here your Interaction code can safely manipulate the pending queue */ });
BIC-JQM code to run to check BIC Ready
require(['bic'], function (BIC) { BIC.whenPopulated().then(function () { console.log('ready and populated'); // TODO: do stuff! }); }); // Or require(['bic'], function (BIC) { $(document).one('pageshow', function () { console.log('pageshow'); }); });