Skip to content

Instantly share code, notes, and snippets.

@andywenk
Created April 1, 2010 09:53
Show Gist options
  • Save andywenk/351613 to your computer and use it in GitHub Desktop.
Save andywenk/351613 to your computer and use it in GitHub Desktop.
// more or less a note to myself ...
//
// This is an example for displaying a (say) PDF print button (id = submit4) only, if a particular
// button out of a set of multiple button is pressed
//
// requires jQuery
// originally there was some more stuff in the Attendees object
Attendees = {};
// handling the pdf button
Attendees.pdf = {
// the PDF button (respectively the div in which it lives) is not displayed, only in case
// a navigation button with id = a2 is clicked
pdf_button_is_not_visible: function() {
// if we want to display the the PDF button (decided by a PHP script), first we set it
// to display none
if($('submit4')) {
$('submit4').style.display = 'none';
};
// if the navigation button id = a2 is clicked, we display the PDF button. This means
// we display the div area and the logic in the PHP script decides if the PDF button shall
// be displayed at all. active_tab is a hidden field where the status of the actual
// navigation button is stored
if($('active_tab').value == 'a2') {
this.display_pdf_button();
};
},
// shows the PDF button div
display_pdf_button: function() {
if($('submit4')) {
$('submit4').style.display = 'inline';
};
},
// For all the multiple navigation buttons, we register an EventHandler for the "click" event.
// The callback is the pdf_button_is_not_visible form above. It manages if the button shall be
// displayed
add_event_handler: function() {
var that = this;
for(var i = 1; i < 8; ++i) {
if(jQuery('#a' + i)) {
jQuery('#a' + i).bind('click', function() {
that.pdf_button_is_not_visible();
});
}
}
},
// calls the action to print the pdf in the controller
printpdf: function(id, uid, aid) {
location.href = '/event/attendees/printpdfhotel/id/' + id + '/uid/' + uid + '/aid/' + aid;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment