Try delegating an event of cancel and submit like following:
For Cancel
$(document.body).on('click',"#cancel",function () {
$('#popover').popover('hide');
alert('popover closed');
});
For Submit
$(document.body).on('submit','#form',function (e) {
e.preventDefault();
alert('Form submitted');
});
Event delegation allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future.