0
      $.ajax({
        type: "GET",
        url: "@Url.Action("EditNote", "Home")",
        data: { id: noteId },
        cache: false,
        dataType: "json",
        success: function (mynote) {
            $("#edit-popup").html(mynote.Html);
            $("#edit-popup").dialog({
                resizable: true,
                height: 210,
                width: 510,
                modal: true,
                buttons: {
                    Save: function () {
                        var boxval = $("#edit-content").val();

                        if (!boxval) {
                            showError("Can't save an empty note");
                            return;
                        }
                        $.ajax({
                            type: "POST",
                            url: "@Url.Action("SaveNote", "Home")",
                            data: { id: noteId, content: boxval },
                            cache: false,
                            dataType: "json",
                            success: function (data) {
                                if (data.Message) {
                                    showError(data.Message);
                                } else {
                                    $(liId).replaceWith(data.Html);
                                    $(liId).slideDown("slow");
                                    $("#flash").hide();
                                    $("#edit-popup").dialog("close");
                                }

                            }

                        }); //end save call
                    }, // end ok button
                    Cancel: function () {
                        $("#flash").hide();
                        $(this).dialog("close");
                    }
                },
                close: function () {
                    $("#flash").hide();
                } //end buttons
            }); //end modal edit
        }
    }); //end ajax call

On success after the dialog closes I need it to update the dynamic content that was loaded I am using the replaceWith() but it does not change the content, what am i doing wrong, I am really really new at this.

Daniel
  • 11
  • 3
  • what is `liId` in success block? – maximus ツ Aug 25 '13 at 09:49
  • I am using MVC 4, and it has a helper function to render a partial view into valid html
    section that needs to replace the one that was edited.
    – Daniel Aug 25 '13 at 09:50
  • One the main page I load notes with
    Notes
    etc. the liId is the id of the div element
    – Daniel Aug 25 '13 at 09:52
  • can you check javascript console if any error occurred? – maximus ツ Aug 25 '13 at 09:53
  • At the top i am doing this var noteId = e.replace("edit-", ""); var liId = '#bar-' + noteId; – Daniel Aug 25 '13 at 09:54
  • Ok, I have gone through the console, I might have a problem with the load notes, Its not rendering the id attribute but only a class attribute, this I have noticed in page inspector, and the console told me there is no id.attr – Daniel Aug 25 '13 at 10:08
  • maximus you are a star, without knowing it :), I just added the id attribute into the partial view and it works, i have another error in the console, seeing I am not sure what the problem there gonna have to figure it out this - I got the code from another place and had to modify it, error I get if you know maybe? ReferenceError: dateFormat is not defined, I presume it is a function not present? in the part data: { id: Id, lastDate: dateFormat(date, 'isoUtcDateTime') }, It sure has to be a plugin? can you tell me which one? – Daniel Aug 25 '13 at 10:13
  • glad, it worked out :) `dateFormat` is not a native function. You need to use something like this http://stackoverflow.com/questions/1056728/formatting-a-date-in-javascript to format the date or may be you forgot to include that lib. if you use firebug, you can find what it is. – maximus ツ Aug 25 '13 at 10:58

0 Answers0