0

我最近才开始使用 Asp.Net MVC,目前我一无所知。所以我的任务是本地化 .js 文件中的文本。我的问题是我似乎无法在浏览器中显示此对话框标签,我要替换的文本是“删除 A 到 B”。我已经尝试通过将“this.a”替换为该文本来使用我的变量“a”,但它不起作用。

function Remove() {

   var a = "";

   this.Load = function () {
      ...`enter code here`
        });

   this.InitEventHandlers = function () {
        $("#updateRemove").click(function (e) {
            amplify.publish("UpdateRemove");
            e.preventDefault();
        });

   $("#removeA").click(function () {
            $("#removeA").dialog({
                title: "Remove A to B",
                width: 300,
                autoOpen: true,
                modal: true,
                draggable: false,
                resizable: false,
                dialogClass: "RemoveB",
                open: function () { $(this).appendTo("RemoveC"); }
            });
        });
...
4

1 回答 1

0

您需要存储“this”的引用,因为在删除函数内的对象中,上下文是当前对象。

做这个:

function Remove() {

  var that = this;

  that.a = "";

  $("#removeA").click(function () {
    $("#removeA").dialog({
      title: that.a,

你可以在这里阅读更多内容:http: //javascript.crockford.com/private.html

于 2013-01-22T08:02:05.650 回答