【发布时间】:2011-05-25 04:42:30
【问题描述】:
我有一个使用 .load() 方法加载的表单。
$(function() {
$('#items,#button-search').hide();
$("#companies").click(function() {
$(this).attr("value","");
$('#address,#new-company-form').empty();
});
$( "#companies" ).autocomplete({
source: ";companies",
minLength: 2,
select: function( event, ui ) {
if(ui.item.id == "create-new-company") {
// call the new company form
$('#address').empty();
$('#new-company-form').load(';company_form #autoform');
}
else
{
$('#new-company-form').empty();
$.ajax({
type: 'GET',
url: ';addresses?company=' + ui.item.id,
dataType: 'json',
// process the addresses
success: function(json) {
var opts = '';
$.each(json, function(k, v) {
opts += '<option>' + v + '</option>';
});
$('#address').html('<select>' + opts + '</select>');
}
}); //end ajax call to address
}
} // end select address
}); // end autocomplete
}); // end function
在第 15 行,我有
$('#new-company-form').load(';company_form #autoform');
如果我删除#autoform,则 ;company_form html 中的 javascript 可以工作,否则不会加载。
如何让它工作?
谢谢
【问题讨论】:
-
它是我使用的框架的一部分。 hforge.org/itools
标签: jquery load parameter-passing