1

Hi I use Bootstrap tab menu and ShinDarth's Nestable++ menu editor My problem live demo

$("a[data-toggle='tab']").on("shown.bs.tab", function(e) {
  var hedef = $(e.target).attr("href");
  alert(hedef);
  if (hedef == "#footmenu") {
    var nestabad = "#nestable2";
    var menutip = "alt";
    var nestableList = $("#nestable2 > .dd-list");
  } else if (hedef == "#headmenu") {
    var nestabad = "#nestable";
    var menutip = "ust";
    var nestableList = $("#nestable > .dd-list");
  }
});
var deleteFromMenu = function () {
  var targetId = $(this).data('owner-'+menutip+'-id');
  alert(JSON.stringify($(this).data()));
  var target = $('[data-'+menutip+'-id="' + targetId + '"]');
  alert(JSON.stringify(target));
  var result = confirm("Delete " + target.data('name') + " and all its subitems ?");

  if (!result) {
    return;
  }

  // Remove children (if any)
  target.find("li").each(function () {
    deleteFromMenuHelper($(this));
  });

  // Remove parent
  deleteFromMenuHelper(target);
    target.data();
  // update JSON
  updateOutput($('#nestable2').data('output', $('#json-output2')));
  updateOutput($('#nestable').data('output', $('#json-output')));
};

always tabs menu change menutip variable defined. I delete menu link before switch menu page menutip defined. TWO confirm(1.undefined variable,2.defined variable) after menu link deleted

Help me!

  • `menutip` is `var` scoped to the method that processes the bs.tab event. It's not a global variable. So any change you make to it will not exist when you get to the `deleteFromMenu` function. If you want it to be more global, take the var off of the variable, and declare it as a var at a higher scope that is shared by both methods. – Taplar Aug 15 '18 at 21:12
  • Possible duplicate of [What is the scope of variables in JavaScript?](https://stackoverflow.com/questions/500431/what-is-the-scope-of-variables-in-javascript) – Taplar Aug 15 '18 at 21:13
  • Taplar go to the live demo before üst menü click after alt menü click last x (delete button) click show alert problem –  Aug 15 '18 at 21:13

0 Answers0