Skip to content

Commit f4f1f18

Browse files
committed
⬆️ Fixed #37
1 parent def5d7d commit f4f1f18

File tree

4 files changed

+60
-40
lines changed

4 files changed

+60
-40
lines changed

src/fields/fieldDateTime.vue

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
}
5555
else
5656
console.warn("Bootstrap datetimepicker library is missing. Please download from https://eonasdan.github.io/bootstrap-datetimepicker/ and load the script and CSS in the HTML head section!");
57+
},
58+
59+
beforeDestroy() {
60+
if ($.fn.datetimepicker)
61+
$(this.$el).data("DateTimePicker").destroy();
5762
}
5863
};
5964
</script>

src/fields/fieldMasked.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
}
1616
else
1717
console.warn("JQuery MaskedInput library is missing. Please download from https://github.com/digitalBush/jquery.maskedinput and load the script in the HTML head section!");
18-
}
18+
},
19+
20+
beforeDestroy() {
21+
if ($.fn.mask)
22+
$(this.$el).unmask();
23+
}
1924
};
2025
</script>
2126

src/fields/fieldNoUiSlider.vue

+44-39
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,59 @@
33
</template>
44

55
<script>
6-
import abstractField from "./abstractField";
7-
import { isArray, defaults } from "lodash";
6+
import abstractField from "./abstractField";
7+
import { isArray, defaults } from "lodash";
88
9-
export default {
10-
mixins: [abstractField],
9+
export default {
10+
mixins: [abstractField],
1111
12-
data() {
13-
return {
14-
slider: null
15-
};
16-
},
12+
data() {
13+
return {
14+
slider: null
15+
};
16+
},
1717
18-
watch: {
19-
model: function() {
20-
if (window.noUiSlider && this.slider && this.slider.noUiSlider) {
21-
this.slider.noUiSlider.set(this.value);
18+
watch: {
19+
model: function() {
20+
if (window.noUiSlider && this.slider && this.slider.noUiSlider) {
21+
this.slider.noUiSlider.set(this.value);
22+
}
2223
}
23-
}
24-
},
24+
},
25+
26+
methods: {
27+
onChange(value) {
28+
if (isArray(value)) {
29+
// Array (range)
30+
this.value = [parseFloat(value[0]), parseFloat(value[1])];
31+
} else {
32+
// Single value
33+
this.value = parseFloat(value);
34+
}
35+
}
36+
},
2537
26-
methods: {
27-
onChange(value) {
28-
if (isArray(value)) {
29-
// Array (range)
30-
this.value = [parseFloat(value[0]), parseFloat(value[1])];
38+
ready() {
39+
if (window.noUiSlider) {
40+
this.slider = this.$el;
41+
window.noUiSlider.create(this.slider, defaults(this.schema.sliderOptions || {}, {
42+
start: this.value != null ? this.value : this.schema.min,
43+
range: {
44+
"min": this.schema.min,
45+
"max": this.schema.max
46+
}
47+
}));
48+
this.slider.noUiSlider.on("change", this.onChange.bind(this));
3149
} else {
32-
// Single value
33-
this.value = parseFloat(value);
50+
console.warn("noUiSlider is missing. Please download from https://github.com/leongersen/noUiSlider and load the script and CSS in the HTML head section!");
3451
}
35-
}
36-
},
52+
},
3753
38-
ready() {
39-
if (window.noUiSlider) {
40-
this.slider = this.$el;
41-
window.noUiSlider.create(this.slider, defaults(this.schema.sliderOptions || {}, {
42-
start: this.value != null ? this.value : this.schema.min,
43-
range: {
44-
"min": this.schema.min,
45-
"max": this.schema.max
46-
}
47-
}));
48-
this.slider.noUiSlider.on("change", this.onChange.bind(this));
49-
} else {
50-
console.warn("noUiSlider is missing. Please download from https://github.com/leongersen/noUiSlider and load the script and CSS in the HTML head section!");
54+
beforeDestroy() {
55+
if (this.slider)
56+
this.slider.noUiSlider.off("change");
5157
}
52-
}
53-
};
58+
};
5459
</script>
5560

5661
<style lang="sass">

src/fields/fieldSelectEx.vue

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
else
5252
console.warn("Bootstrap-select library is missing. Please download from https://silviomoreto.github.io/bootstrap-select/ and load the script and CSS in the HTML head section!");
5353
54+
},
55+
56+
beforeDestroy() {
57+
if ($.fn.selectpicker)
58+
$(this.$el).selectpicker("destroy");
5459
}
5560
};
5661
</script>

0 commit comments

Comments
 (0)