index.php (js called in <header></header)
$( "button" ).click(function()
var context = $(this).attr('type');
var page_type = $(this).attr('page');
var referrer = $(this).attr('referrer');
var form_type = $(this).attr('form');
var object_id = $(this).attr('object');
var postData = 'page_type='+page_type+'&form_type='+form_type+'&referrer='+referrer+'&id='+object_id;
if (context == 'post_form')
var formData = $('#submit_content').serialize();
postData = postData+'&context=post_form&'+formData;
if ((context == 'load_form') || (context == 'filter_form'))
postData = postData +'&context=load_form';
if (context == 'filter_form')
var filter1 = $('select[name=filter1]').val();
var filter2 = $('select[name=filter2]').val();
var filter3 = $('select[name=filter3]').val();
postData = postData + '&filter1='+filter1+'&filter2='+filter2+'&filter3='+filter3;
error: function(XMLHttpRequest, textStatus, errorThrown)
An example of a button I use in index.php
<button type="load_form" page="page" referrer="navigation" form="edit" object="">TEST</button>
So far...everything is all right. Hitting the button submits the variables to sl.php and the output I get from sl.php is also ok.
But, if I get buttons in the output, I would like them to use the ButtonManager function but this function is unknown there.
The only trick I have found to make it work is to add the following to the server output: var testvar = ButtonManager();
This works but the problem is that my function is called multiple times (at least twice).
I'm perhaps looking at it the wrong way but given my limited experience in JS, there might be a simpler alternative.