2021年3月9日星期二

Code does not reflect updates to category name in each text box

the code does not allow me to update/edit the name in each text box. I've reviewed the code several times but could not find any errors. Grateful for any help. Thanks.

THE HTML

        /*           *  Confirm category deletion           */           $("body").on("click", "a.delete", function () {                        if (!confirm("Confirm page deletion")) return false;          });            /////////////////////////////////////////////////////////            /*           *  Rename Category           */            var originalTextBoxValue;            $("table#pages input.text-box").dblclick(function () {              originalTextBoxValue = $(this).val();              $(this).attr("readonly", false);          });            $("table#pages input.text-box").keyup(function (e) {              if (e.keyCode == 13) {                  $(this).blur();              }          });            $("table#pages input.text-box").blur(function () {                var $this = $(this);              var ajaxdiv = $this.parent().find(".ajaxdivtd");              var newCatName = $this.val();              var id = $this.parent().parent.attr("id").substring(3);              var url = "/admin/shop/RenameCategory";                if (newCatName.length < 2) {                  alert("Category name must be at least 2 characters long.");                  $this.attr("readonly", true);                  return false;              }                $.post(url, { newCatName: newCatName, id: id }, function (data) {                  var response = data.trim();                    if (response == "titletaken") {                      $this.val(originalTextBoxValue);                      ajaxdiv.html("<span class='alert alert-danger'>That title   

is taken!").show(); } else { ajaxdiv.html("The category name has been changed!").show(); }

                setTimeout(function () {                      ajaxdiv.fadeOut("fast", function () {                          ajaxdiv.html("");                      });                  }, 2000);                  }).done(function () {                      $this.attr("readonly", true);              });            });            ///////////////////////////////////////////            });    </script>  

\\

https://stackoverflow.com/questions/66556959/code-does-not-reflect-updates-to-category-name-in-each-text-box March 10, 2021 at 09:06AM

没有评论:

发表评论