Skip to content

Instantly share code, notes, and snippets.

@mahmut-gundogdu
Created September 12, 2017 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmut-gundogdu/f34ff931dc0c5e207fc018451b35f34f to your computer and use it in GitHub Desktop.
Save mahmut-gundogdu/f34ff931dc0c5e207fc018451b35f34f to your computer and use it in GitHub Desktop.
asp.net mvc de form içerisinde form açamıyoruz. bazen gerekiyor. Bu kod url verilen html getirip içerisindeki formu ajax ile ele almayı(handle) sağlıyor
function getDataFromPartialbyAjax(url, mainPanel, callbackFn) {
function getModalData(response) {
if (response.data != undefined) {
//it is json
callbackFn(response.data);
mainPanel.empty();
} else {
//it is html
mainPanel.html(response);
$.validator.unobtrusive.parse($("form", mainPanel));
init(mainPanel);
var form = $('form', mainPanel);
form.on('submit', function () {
$.ajax({
url: this.action,
type: this.method,
data: $(this).serialize(),
success: getModalData
});
return false;
});
}
}
$.get(url).success(getModalData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment