I am trying to figure out why my javascript is not running when clicking a button. Ive checked to make sure the javascript file is loading correctly, and there are no errors in the console. When I run the javascript code in the console, the code successfully runs and does what it is supposed to do, however when I click the button, it does not fire. I believe all my syntax is correct, so I am not sure what is causing this issue.
Below is the HTML for the button:
<input class="btnSaveParameters" id="btn_SaveCriteria" onclick="return btn_SaveCriteria_onclick();" type="button" value="Save Subscription"/>
Below is the Javascript function that runs correctly in the console, but does not fire when clicking the button:
function btn_SaveCriteria_onclick() {
//Testing if function fires:
window.alert(5 + 6);
var availableSelects = [];
$("Select").each(function () {
availableSelects.push($(this).attr("id"));
});
if (
$("#" + availableSelects[1])
.find(":selected")
.text() + $("#" + availableSelects[2])
.find(":selected")
.text()+$("#" + availableSelects[2])
.find(":selected").text() ==='AllAllAll'
) {
$(".PageTitle").append("<div id='dialog' title='Parameter Warning'>You cannot select all for all 3 filters</div>");
$("#dialog").dialog();
} else {
var t = document.getElementById("modal-form").cloneNode(true);
t.style.display = "inline";
var options = {
title : "Add a Description to your Subscription",
width : 500,
height : 100,
dialogReturnValueCallback : MyDialogClosed,
html: t
};
};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
}
Can anyone see why the javascript is not firing with the button click?