Problems with inputs in ajax loaded content
Hi, I have problems with inputs which are loaded via ajax. This video shows, what's the problem: http://www.youtube.com/watch?v=7PBdKjxI7Xk
- Textbox works as I expect. This input is not loaded with ajax.
- Buttons don't work properly. They do nothing. This part is loaded with ajax from server.
- The page's part with accordion is loaded with ajax from the server and the content of accordion is loaded from the server with ajax again (after expand). In this case inputs don't work and buttons are sending request to server :(
The ajax call looks like:
$('#accAcounts li').click(function (e) {
if ($(this).hasClass('active')) {
loadTabContent("/Email/AccountEdit", $(this).attr('id'));
}
});
function loadTabContent(tabUrl, id) {
jQuery.ajax({
url: tabUrl + '/' + id,
cache: false,
success: function (message) {
$("#" + id + " div").empty().append(message);
}
});
}
Need reinit input-control plugin after ajax loaded.
6 ôåâð. 2013, â 19:21, mytrixcz [email protected] íàïèñàë(à):
Hi, I have problems with inputs which are loaded via ajax. This video shows, what's the problem: http://www.youtube.com/watch?v=7PBdKjxI7Xk
- Textbox works as I expect. This input is not loaded with ajax.
- Buttons don't work properly. They do nothing. This part is loaded with ajax from server.
- The page's part with accordion is loaded with ajax from the server and the content of accordion is loaded from the server with ajax again (after expand). In this case inputs don't work and buttons are sending request to server :(
The ajax call looks like:
$('#accAcounts li').click(function (e) { if ($(this).hasClass('active')) { loadTabContent("/Email/AccountEdit", $(this).attr('id')); } });
function loadTabContent(tabUrl, id) { jQuery.ajax({ url: tabUrl + '/' + id, cache: false, success: function (message) { $("#" + id + " div").empty().append(message); } }); } — Reply to this email directly or view it on GitHub.
Ñ óâàæåíèåì Ñåðãåé Ïèìåíîâ [email protected]
Thank you for fast reply, but can you tell me, how exactly It's possible to reinit inputs? For accordion works reinit fine, but for inputs without luck..
$(function(){
$.Input();
});
.. this doesn't work
use only $.Input() without $(function(){ ... });
for example: function afterAjaxComplete () { $.Input(); }
So, problem is solved. There is the issue, that $.Input() must be call during "success" in ajax query script.
This works fine.
function loadTabContent(tabUrl, id) {
jQuery.ajax({
url: tabUrl + '/' + id,
cache: false,
success: function (message) {
$("#" + id + " div").empty().append(message);
$.Input();
}
});
}
If you call $.Input() after ajax script, this will not work. Is interesting that eg. accordion hasn't this issue and it can be reinited after ajax call, anywhere on the page.