次のようにドロップダウンに動的にバインドしているデータがあります。
if (product.oPTIONS.length > 0) {
$.each(product.oPTIONS, function (idx, options) {
/*appending the each option to a label*/
$("#productdetails").append('<div class="clear">');
$("#productdetails").append('<label>' + options.OptionName + '</label>');
if (options.values.length > 0) {
var stringBuilder = [];
/*Creating a select tag for the Retrieved options*/
$("#productdetails").append('<select id="' + options.OptionName + '" onchange="getimage($(this).val())" ><option>Choose</option>');
$.each(options.values, function (idx, values) {
/*Binding options to the Created select tag For an Option based on option Id*/
$("" + "#" + options.OptionName + "").append('<option value="' + values.sku + '">' + values.OptionValue + '</option>');
});
stringBuilder.push('</select>');
$("#productdetails").append(stringBuilder.join(''));
}
$("#productdetails").append('</div>');
})
}
今の私の状況は、ドロップダウンの値の一部が繰り返される可能性があるということです。その場合、ドロップダウンにバインドする必要があるのは1つの値だけです。
example
Size:DropDown
[S]
[XXl]
[s]
[xl]
Fit:DropDown
[Slim]
[Regular]
[Slim]
[AppleCut]
これはケースです、ここでは [S]、[Slim] のサイズのみ、Fit ドロップダウンを 1 回だけバインドしたいです。