Difference between revisions of "Include Javascript in the workflow"

From EPrints Documentation
Jump to: navigation, search
(Pure Javascript)
Line 3: Line 3:
 
==Pure Javascript==
 
==Pure Javascript==
  
EPrints stores javascript files in <eprints_root>/archives/<archive_id>/cfg/static/javascript/auto/ and it EPrints ships with PrototypeJS.
+
This should be the prefered method although it is not always straight forward to use depending what your trying to do. EPrints stores javascript files in <eprints_root>/archives/<archive_id>/cfg/static/javascript/auto/ and it EPrints ships with PrototypeJS. If your workflow problem is specific enough you can simply us $$('any-css-selectors').whateveryouneedtodo()
 +
 
 +
==Custom input renderer==
 +
 
 +
You can over write the input renderer for the field you wish to modify
 +
 
 +
 
 +
==XHTML Component==
 +
 
 +
You if you are in hurry or prototyping then you can use a HTML Component
 +
 
 +
<source lang='xml'>
 +
 
 +
<component type='XHTML'>
 +
<script type='text/javascript'>
 +
        //your javascript goes here
 +
</script>
 +
</component>
 +
 
 +
</source>
 +
 
 +
The downside of this approach is it leaves a tiny bit of workflow component floating in your workflow so you probably wouldn't use it in production.
  
  
  
 
[[Category:Howto]]
 
[[Category:Howto]]

Revision as of 20:08, 17 June 2015

Sometimes you need to augment an EPrints workflow in a specific way. One of the ways you can do this is using javascript but it is not immediately clear how to do that. There are several options available which may suit what you need to do.

Pure Javascript

This should be the prefered method although it is not always straight forward to use depending what your trying to do. EPrints stores javascript files in <eprints_root>/archives/<archive_id>/cfg/static/javascript/auto/ and it EPrints ships with PrototypeJS. If your workflow problem is specific enough you can simply us $$('any-css-selectors').whateveryouneedtodo()

Custom input renderer

You can over write the input renderer for the field you wish to modify


XHTML Component

You if you are in hurry or prototyping then you can use a HTML Component

<component type='XHTML'>
<script type='text/javascript'>
        //your javascript goes here
</script>
</component>

The downside of this approach is it leaves a tiny bit of workflow component floating in your workflow so you probably wouldn't use it in production.