javascript - jquery dialogue destroy syntax -
i have dialog box loads partial view, called number of different views in mvc 4 app. has text area , small notice of how many characters remaining in text area. works fine on page load, when dialog box closed, whether send button or close button in dialog titlebar, when reopened '#textarea_feedback' div content disappears until page reload. believe should using dialog('destroy') cannot seem syntax right. either has no effect or displays partialview @ bottom of page. please advise, hope i've included enough code identify issue. thanx
$(document).ready(function () { var text_max = 160; $('#textarea_feedback').html(text_max + ' characters remaining'); $('#txtmessage').keyup(function () { var text_length = $('#txtmessage').val().length; var text_remaining = text_max - text_length; $('#textarea_feedback').html(text_remaining + ' characters remaining'); }); $('#send').click(function (e) { if ($('#txtsmsmessage').val().trim()) { e.preventdefault(); $.ajax({ type: "post", data: $('form#composer').serialize(), url: '/mycontroller/myaction', success: function (data) { alert('sent'); $('#composer').closest("div.ui-dialog-content").dialog("close"); }, error: function (a, b, c) { $("#composer").unblock(); alert(b); } }); //$('#composer').closest("div.ui-dialog-content").dialog("destroy"); } }); //var dialog = $('#composer').closest("div.ui-dialog-content").dialog(); //console.debug(dialog); //dialog.on("dialogbeforeclose", function (event, ui) { // dialog.dialog('destroy') //}); });
wanted post answer in case else, lshetty's comment lead me in right direction. added close function of ajax call created dialog box:
$.ajax({ url: ... type: "post", success: function (responsetext, textstatus, xmlhttprequest) { dialog.html(responsetext); dialog.dialog({ ... title: 'send message', open: function () { ... }, close: function () { $(this).dialog('destroy').remove() }, ... }); }
Comments
Post a Comment