Skip to content

Bridge API

gga edited this page Dec 18, 2012 · 4 revisions

Bridge API

The API provided by Calatrava to the kernel of your app is actually quite small.

  • calatrava.bridge.changePage(<target>): Changes the current page to the page named target.

  • calatrava.bridge.openUrl(<url>): Open the given URL in a new web browser, however makes the most sense for the native platform.

  • calatrava.bridge.log(<message>): Log the given message for debugging purposes.

  • calatrava.bridge.request(<options>): Issue an AJAX request. options is an object that can contain the following keys.

    • url: The URL to issue the request to.
    • method: The HTTP method to use.
    • body: The body to include with the request. Optional.
    • success: A callback to invoke on success.
    • failure: A callback to invoke if the request fails. Optional.
    • contentType: The Content-Type header to use. Optional.
    • customHeaders: A hash of additional custom headers to attach to the request. Optional.
  • calatrava.bridge.pages.pageNamed(<pageName>): Returns the page reference for the named page.

  • calatrava.bridge.timers.start(<timeout>, <callback>): Start a timer to fire after the timeout, given in seconds. When the timeout expires, the callback is called. Returns a timer handle.

  • calatrava.bridge.plugins.call(<pluginName>, <method>, <args>): Calls a previously registered plugin named <pluginName>. Execute the <method>, with <args>. Exactly what the method means, and if one is even used is up to the plugin to define. This will forward on to the native implementation of your plugin.

Something went wrong with that request. Please try again.