jquery ajax converting form select options
Banging my head against the wall here. I've got a button opening a dialog box with a form in it. The form is generated via PHP then loaded via ajax as content into the dialog. It all seem to be working except for the selects. The option text is moved outside the option tag.
The calling jquery:
$.ajax({
type: 'POST',
url: '/wizard/basic-info/contact',
dataType: 'html',
success: function(html) {
console.log(html);
$('#dialog-form').append(html);
$('#dialog-form').dialog("open");
}
});
The console.log just inside the success function produces basically:
<form action="" method="post" id="contact">
<label>Payment Terms</label>
<select name="payment_terms" id="payment_terms">
<option value="" selected="selected"></option>
<option value="net15">Net 15</option>
<option value="net30">Net 30</option>
<option value="net45">Net 45</option>
<option value="net60">Net 60</option>
<option value="cod">COD</option>
<option开发者_如何学C value="consignment">Consignment</option>
</select>
But inspecting the DOM of the finished form yeilds:
<form action="" method="post" id="contact">
<label>Payment Terms</label>
<select name="payment_terms" id="payment_terms">
<option value="" selected="selected"></option>
<option value="net15"></option>Net 15
<option value="net30"></option>Net 30
<option value="net45"></option>Net 45
<option value="net60"></option>Net 60
<option value="cod"></option>COD
<option value="consignment"></option>Consignment
</select>
Obviously the text for each option is on the wrong side. Any suggestions?
Answered--- Oop, my bad. I coded my custom element view script wrong. I added a trailing slash to the option tag. This:
<option value="net15" />Net 15</option>
Should have been:
<option value="net15">Net 15</option>
My bad, thanks for the help.
I've tried your code. It works perfect. It might be becouse of the version of the jquery you're using. I've tried with v1.6.2. and UI v.1.8.16
精彩评论