私は製品コンフィギュレーターに取り組んでいます。Ractivejs を使用しています。
2 つの問題があります。
- step1 で option1 をチェックすると、step2 で option1 もチェックされます (なぜですか?)
- 最初のステップで製品 2 を選択した場合、青色を非表示にする方法が必要です
テンプレート:
{{#steps[currentStep].options:i}}
<div class='radio'>
<label>
<input type='radio' name='group{{currentStep}}' id='radio{{currentStep}}{{i}}' value='option{{currentStep}}{{i}}'>
{{name}}
</label>
</div>
{{/steps[currentStep].options}}
<button on-click='gotoStep: {{currentStep + 1}}'>next</button>
Javascript:
var ractive, stepsData;
stepsData = [
{ name: 'Products', options: [
{ name: 'Product 1', price: 100 },
{ name: 'Product 2', price: 120 }
]},
{ name: 'Color', options: [
{ name: 'Black', price: 0},
{ name: 'White', price: 5 },
{ name: 'Blue', price: 20 }
]}
];
ractive = new Ractive({
el: '#template',
template: '#tempMain',
data: {
steps: stepsData,
currentStep: 0
}
});
ractive.on( 'gotoStep', function ( event, step ) {
this.set( 'currentStep', step );
});