- Coupon Add/Edit/Delete rule AJAX
This commit is contained in:
gmorel
2013-09-10 20:00:43 +02:00
parent 3ffc948d4b
commit 8be785e9b3
11 changed files with 409 additions and 622 deletions

View File

@@ -1,4 +1,3 @@
{*{$inputs.inputs|var_dump}*}
{foreach from=$inputs.inputs key=name item=input}
<label for="operator">{$input.title}</label>
<div class="row">
@@ -71,6 +70,8 @@
{*</div>*}
<script>
// Init Rules to set
var ruleToSave = {};
ruleToSave['serviceId'] = '{$ruleId}';
ruleToSave['operators'] = {};
@@ -81,22 +82,23 @@
{/foreach}
// Update ruleToSave Array ready to be saved
// Fill in ready to be saved rule array
var onInputsChange = function() {literal}{{/literal}
{foreach from=$inputs.inputs key=name item=input}
$('#{$name}-operator').change(function (e) {
var $this = $(this);
console.log('{$name}-operator changed by ' + $this.val());
ruleToSave['operators']['{$name nofilter}'] = $this.val();
console.log('#{$name}-operator changed ' + $this.val());
console.log(ruleToSave);
});
$('#{$name}-value').change(function (e) {
var $this = $(this);
console.log('{$name}-value changed by ' + $this);
ruleToSave['values']['{$name nofilter}'] = $this.val();
console.log('#{$name}-value changed ' + $this.val());
console.log(ruleToSave);
});
{/foreach}
console.log('will save ');
console.log(ruleToSave);
{literal}}{/literal}
onInputsChange();
</script>