Because the button is being added dynamically your current jQuery registration will not bind. If you use the "on" event binding, it will work with dynamic elements. Try something like the following:
//Replace ".dynamic-button-class" with a target that points to your button.
$(document).on("click", ".dynamic-button-class", function(e) {
e.preventDefault();
doSomething();
});
The "on" syntax binds to all future DOM elements matching the pattern as well as the elements that are present at render.
See here: http://api.jquery.com/on/
and here: Event binding on dynamically created elements?
You'll also want to avoid duplicate event registrations. By binding an event within another, you will re-bind the event every time the parent event is triggered, which is probably not what you want.
Instead, consider a solution like this:
//This method is registered once for all buttons with a "dynamic-button" class attribute and is triggered for each one clicked.
$(document).on("click", ".dynamic-button", function(e) {
//Load the values stored in the hidden fields.
var formStartDate = $(e.currentTarget).closest("input[name='StartDate']").val();
//etc...
$(document).trigger("calendar-button-clicked", {StartDate: formStartDate}); // Pass the form arguments as a JavaScript object to the calendar-button-clicked event hander
});
$(document).bind("calendar-button-clicked", function(e, data) {
//Do something with the values in data.
});
//Single event triggered when a calendar selection is made
$(document).bind("add-button", function(e, data) {
//Code that adds your button to the page here but also checks to see if the button has already been added.
//persist the values from Data into some kind of form hidden form fields.
console.log(data.StartDate);
});
$("#calendar").fullCalendar({
select: function(start, end, jsEvent, view){
$(document).trigger("add-button", {StartDate: start, EndDate: end, SourceEvent: jsEvent, View: view});
}
});
EDIT: Here is a quick fiddle i set up that works and demonstrates the concept.
http://jsfiddle.net/xDaevax/5282Q/