Adding a balloon help for fields

[edit|delete]

Every field in web2py has a unique name and id. Look at the generated html to figure out the ID for your fields. Say you want to add a balloon to a field with id="mytable_myfield".

Download the jquery plugin http://plugins.learningjquery.com/cluetip

Include the .js files in the view that needs it

<script src="{{=URL(r=request,c='static',f='jquery.dimensions.js')}}" type="text/javascript"></script>
<script src="{{=URL(r=request,c='static',f='jquery.cluetip.js')}}" type="text/javascript"></script>

Add somewhere the following code:

<script>
$(document).ready(function(){
  $('#mytable_myfield').attr('title','Ballon Header Text|Balloon Body Text').cluetip({splitTitle: '|'});
  // add one entry for every field that needs a balloon
});
</script>

The js files have to be put in yourapp/static/ Also make sure you run a current version of web2py that includes the basic jquery.js



Post a comment