0

I just recently started in Asp.Net MVC and I am just clueless at the moment. So my task is to localise text in .js files. My problem is that I can't seem to display this dialog label in my browser, the text I want to replace is "Remove A to B". I have tried using my variable 'a' by going 'this.a' in the place of this text but it doesn't work.

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"); }
            });
        });
...
zanmad07
  • 3
  • 3

1 Answers1

0

you need to store the reference of 'this' because in the object inside the remove function the context is the current object.

do this:

function Remove() {

  var that = this;

  that.a = "";

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

you can read a little bit more here: http://javascript.crockford.com/private.html

hereandnow78
  • 14,094
  • 8
  • 42
  • 48
  • I'm sorry if I was unclear earlier, appreciate all the responses. It was a variable scope issue in the end, so sorry :-) works now. – zanmad07 Jan 22 '13 at 12:59