I do know how to get the name of nav-tab when it is shown, but I am trying to get the name of the tab of a child element when the child element is changed. Just getting the name of the last tab clicked/shown won't help. I am using asp.net MVC Razor and need to find out what changed on the page and on what tabs. The user technically could click tabs without changing anything. I tried doing something like this:
$('body').on('change', '.form-control', function () {
var tab = this.closest('nav-tab');
})
I have also tried:
$('body').on('change', '.form-control', function () {
var tab = this.closest('.nav-tab');
})
but that did not work. There may be a better way to accomplish what I need. Any assistance is greatly appreciated.
Have you looked through the DOM to see where its nested? I've had luck in tables just going up to the TR then doing a find with the class. Maybe this sample will help?
$(".ctxMenu li").click(function () {
var thisLink = $(this).closest("tr").find("input[id$='" + $(this).attr("data-action") + "']").attr("id");
if (thisLink != "undefined") {
$(this).closest("tr").find("input[id$='" + $(this).attr("data-action") + "']").click();
}
$(".ctxMenu").hide(100);
});
$(".jqSaveChangeDiv").change(function (e) {
$(this).closest("div").find(".jqQuickUpdate2").trigger("click");
console.log("Updated " + $(this).closest("div").find(".jqQuickUpdate2").attr("id"));
});