Skip to content

Commit

Permalink
Merge pull request #3 from gruz/patch-1
Browse files Browse the repository at this point in the history
Makes the Range field work with Orchid listeners
  • Loading branch information
agoalofalife authored Jan 12, 2023
2 parents 3b608a1 + f79560e commit 2ed8ac9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
12 changes: 10 additions & 2 deletions resources/js/controllers/range_controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
export default class extends window.Controller {
connect() {
let value = this.data.get('value');
$(this.element.querySelector(".js-range-slider")).ionRangeSlider();
let range = $(".js-range-slider").data("ionRangeSlider");

let input = this.element.querySelector(".js-range-slider");

$(input).ionRangeSlider({
onFinish: function (data) {
input.dispatchEvent(new Event('change'));
},
});

let range = $(input).data("ionRangeSlider");

if (value !== null) {
let [from, to] = value.split(';');
Expand Down
3 changes: 2 additions & 1 deletion resources/views/fields/range.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@component($typeForm, get_defined_vars())
<div data-controller="range" data-range-value="{{$value}}">
<input type="text" class="js-range-slider" {{$attributes}}
data-type="double"
data-type="{{$type}}"
data-min="{{$min}}"
data-max="{{$max}}"
data-from="{{$from}}"
data-to="{{$to}}"
data-grid="{{$hasGrid}}"
data-skin="{{$skin}}"
/>
</div>
@endcomponent
4 changes: 3 additions & 1 deletion src/Fields/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class Range extends Field
'max' => 1000,
'from' => 0,
'to' => 1000,
'hasGrid' => false
'hasGrid' => false,
'type' => 'double',
'skin' => 'flat',
];

/**
Expand Down

0 comments on commit 2ed8ac9

Please sign in to comment.