我創建上飛一個對話框,當我打開它的第一次它工作得很好,但是當我嘗試重新打開它再一次的功能點擊我創建不起作用。這是我的代碼,它全部在onready函數中。我只是試圖禁用一個輸入字段,並把它放在焦點上。非常感謝。jQueryUI的對話框重新打開輸入文本沒有被禁用
$("#rdoAddressN").click(function(){
var html;
html="<table>"
+"<tr>"
+"<td style='font-size: 14px;' align='center'><strong>D I R E C T O R I O</strong></td>"
+"</tr>"
+"<tr>"
+"<td align='center' nowrap>"
+"<input name='zipcodeType' id='zipcodeTypeCP' value='1' type='radio' style='margin: 10px'><strong>CP</strong>"
+"<input name='zipcodeType' id='zipcodeTypeCol' value='2' type='radio' style='margin: 10px'><strong>Colonia</strong>"
+"<input name='btnBuscarCP' id='btnBuscarCP' value='Buscar' type='button' style='margin: 10px'>"
+"</td>"
+"</tr>"
+"<tr>"
+"<td align='center'>"
+"<input autocomplete='off' name='zipcodeDialog' id='zipcodeDialog' class='zipcodeDialog' size='50' class='authInput' type='text' disabled='disabled' />"
+"</td>"
+"</tr>"
+"<tr>"
+"<td >"
+"<div style='width: 576px; opacity: 0.999999; display: none;' id='divResultsCP' align='center'>"
+"</div>"
+"</td>"
+"</tr>";
+"</table>";
var caja2 = $('<div title="Direccion de Codigos Postales"><p>'+html+'</p></div>');
caja2.dialog({modal: true,show: 'fade',hide: 'fade',height:'auto',width:'auto'});
$(":button").button();
$('#zipcodeTypeCP').click(function(){
$('.zipcodeDialog').remove("disabled");
$('.zipcodeDialog').attr("disabled", true);
$('.zipcodeDialog').attr("disabled", false);
$('.zipcodeDialog').focus();
})
$('#zipcodeTypeCol').click(function(){
$('.zipcodeDialog').remove("disabled");
$('.zipcodeDialog').attr("disabled", true);
$('.zipcodeDialog').attr("disabled", false);
$('.zipcodeDialog').focus();
})
$('#btnBuscarCP').click(function(){
if($('#zipcodeDialog').val().length>3){
$("#divResultsCP").html('<img src="img/ajax-loader-big.gif" />')
$.ajax({
data: "texto="+ $('#zipcodeDialog').val()+"&zipcodeType="+$('input:radio[name=zipcodeType]:checked').val() ,
type: "post",
dataType: "json",
url: "ajax/cp.php",
success: function(data){
switch(data.error){
case undefined:
if(data.mensaje==undefined){
$("#autocomplete_choices").html('');
var tabla="<table class='cptable'>";
tabla+="<tr >"
tabla+="<td ></td>";
tabla+="<td>CP</td>";
tabla+="<td>Colonia</td>";
tabla+="<td>Municipio</td>";
tabla+="<td>Ciudad</td>";
tabla+="<td>Estado</td>";
tabla+="</tr>"
for(index=0; index<data.length; index++) {
tabla+='<tr><td><a href=""> + </a></td><td>' + data[index].postal_code + '</td><td> ' + data[index].colony_name + '</td><td>'+ data[index].d_mnpio+'</td><td>'+ data[index].city_name+'</td><td> '+data[index].state_name+'</td></tr>'
}
tabla+="<table>"
}else{
tabla=data.mensaje;
$("#divResultsCP").addClass("ui-state-highlight");
}
$("#divResultsCP").html(tabla)
$("#divResultsCP").show()
break;
case 'Login':
$("#autocomplete_choices").html('');
alert("Usuario No logueado");
break;
default:
$("#autocomplete_choices").html('');
$("#divResultsCP").html(data.error);
$("#divResultsCP").addClass("ui-state-highlight");
break;
}
}
,error: function (request, status, error) {
alert(request.responseText);
}
});
}
});
})`
請發表您的代碼或其他地區更好,但一個的jsfiddle。 – j08691 2012-04-09 15:22:30
這太可怕了,有了那麼多的html,只需將html放在你的視圖上,然後使用jquery-ui的對話道具讓它不能在開始時顯示,並根據需要打開和關閉它 – SpYk3HH 2012-04-09 15:26:13
http://jsfiddle.net/ maxing80/chQfL/ahi se ve el jsFiddle – maxing80 2012-04-09 17:10:42