Changes

Jump to: navigation, search

Umlaut partial html API javascript helper

681 bytes added, 16:22, 19 June 2012
no edit summary
=WARNING: This is Outdated Documentation!!!!=
 
'''THIS IS OUTDATED DOCUMENTATION''' See new Umlaut documentation at http://github.com/team-umlaut/umlaut/wiki
---------
 
THE CODE DOCUMENTED HERE IS DEPRECATED. PLEASE SEE INSTEAD: [[JQuery HTML Updater]]
 
If you want to include [[Umlaut]]-generated HTML directly on a third party page via javascript, there is a javascript helper script to make that very easy. This helper uses the [[Umlaut partial html API]], but does everything for you. The helper will update your divs, and keep polling Umlaut for new results, continuing to re-update your divs until Umlaut is finished. How often it polls is configured by application config 'poll_wait_seconds', which defaults to 4 seconds.
== Overview ==
Your page needs to include the JS Prototype library. Currently, automatic inclusion of the Prototype library isn't working, so you'll need to include a <script> line to do so. You can link to the prototype library in Umlaut, see example below.  You will first then include an Umlaut javascript file, and then call the embedUmlaut() js function it supplies. You'll need to pass some arguments to embedUmlaut. :
=== Umlaut base URL ===
The second argument is a URL-formatted (KEV) [[OpenURL]] context object.
 
=== Display section mappings ===
The third argument is a javascript hash providing mappings from Umlaut html sections to HTML divs on your page. Umlaut html sections are configured in Umlaut in the "partial_html_map" configuration param, which by default is set to the "bg_update_map" config params :divs key. To see the sections in a default Umlaut installation, see: AppConfig::Base.bg_update_map [http://umlaut.rubyforge.org/svn/trunk/config/initializers/umlaut/resolve_views.rb in resolve_views in svn]. The :divs key of the hash there is an array of hashes, each individual hash has a :div_id key that corresponds to the html_sections id in this api response. For Umlaut developers, the :partial key tells you what [[Rails]] partial is used to generate this section.
};
</script>
 
<!-- include the prototype library -->
<script type="text/javascript" src="http://umlaut.university.edu/javascripts/prototype.js"></script>
 
<!-- now actually load the umlaut js helper, which will do the magic for you -->
<script type="text/javascript" src="http://umlaut.university.edu/javascripts/embed/umlaut-embed-func.js.js"></script> 
<!-- and call embedUmlaut -->
<script type="text/javascript">
</script>
</script>

Navigation menu