jQuery .data() na JavaScript

0

Jak zastapic funkcje .data() z jQuery na JavaScript w edytowaniu pliku? Funkcja pisana jest w Typescript.

Typescript

	valueChanged(newValue) {
		let editSlider = $(this.editSlider).data("ionRangeSlider");
		if (editSlider && editSlider.old_from != newValue){
			editSlider.update({ from: newValue });
		}

		let readOnlySlider = $(this.readOnlySlider).data("ionRangeSlider");
		if (readOnlySlider && readOnlySlider.old_from != newValue) {
			readOnlySlider.update({ from: newValue });
		}
	}

HTML

	<div show.bind="editOnly || parentVM.editMode != 0" class="form-group">
		<label-for>
			<small>${label}</small>
		</label-for>
		<input ref="editSlider" value.two-way="value" type="text">
	</div>
	<div show.bind="!editOnly && parentVM.editMode == 0">
		<small>${label}</small>
		<input ref="readOnlySlider" value.two-way="value" type="text">
	</div>
2

O to chodzi?

this.editSlider.dataset.ionRangeSlider;
0

Oto caly kod w TypeScript:

export class EditIntSliderCustomElement {
	parentVM: any;
	@bindable
	label: string;

	editSlider: HTMLInputElement;
	readOnlySlider: HTMLInputElement;

	@bindable
	min : number;

	@bindable
	max :number;

	@bindable
	step: number = 1;

	@bindable({ defaultBindingMode: bindingMode.twoWay })
	value: number;

	@bindable
	editOnly: boolean = false;

	@bindable
	hideMinMax: boolean = false;

	valueChanged(newValue) {
		let editSlider = $(this.editSlider).data("ionRangeSlider");
		if (editSlider && editSlider.old_from != newValue){
			editSlider.update({ from: newValue });
		}

		let readOnlySlider = $(this.readOnlySlider).data("ionRangeSlider");
		if (readOnlySlider && readOnlySlider.old_from != newValue) {
			readOnlySlider.update({ from: newValue });
		}
	}

	constructor() {
	}

	bind(bindingContext, overrideContext) {
		this.parentVM = bindingContext;
	}

	userChanged(newVal: number){
		if (this.value != newVal) {
			this.value = newVal;
		}

	}

	attached() {
		$(this.editSlider).ionRangeSlider({
			min: this.min,
			max: this.max,
			from: this.value,
			step: this.step,
			hide_min_max: this.hideMinMax,
			onChange: (data) => {
				this.userChanged(data.from);
			}

		});

		$(this.readOnlySlider).ionRangeSlider({
			min: this.min,
			max: this.max,
			from: this.value,
			step: this.step,
			hide_min_max: this.hideMinMax,
			disable: true,
			onChange: (data) => {
				this.userChanged(data.from);
			}

		});
	}
}

0

@let_Majka: Co Ty w ogóle próbujesz zrobisz?

Od kilku tematów zadajesz bardzo dziwne pytania, zaczyna mi to wyglądać na problem X/Y.

Opowiesz dokładnie od czego zaczynasz i jaki efekt próbujesz osiągnąć?

1 użytkowników online, w tym zalogowanych: 0, gości: 1