Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installed via NPM: Uncaught TypeError: $(...).ionRangeSlider is not a function #779

Open
JamesMcFall opened this issue Apr 12, 2022 · 5 comments
Assignees
Labels
Help wanted Person asking for help

Comments

@JamesMcFall
Copy link

I've got a Laravel project. I've just installed jQuery and ion.rangeSlider through npm.

"ion-rangeslider": "^2.3.1",
"jquery": "^3.6.0"

JQuery works as expected in the project. Trying to do the most basic example of a slider (for example below), I get an error:

<input name="MyCoolField" class="form-control" type="text" />

<script>
$(function() {
    $("[name=MyCoolField]").ionRangeSlider({
        type: "double",
        min: 0,
        max: 1000,
        from: 200,
        to: 500,
        grid: true
    });
});
</script>

The Error Is:

jquery.js?8262:4059 Uncaught TypeError: $(...).ionRangeSlider is not a function
    at HTMLDocument.eval (_filter-form.js?a5ef:22:32)
    at mightThrow (jquery.js?8262:3766:1)
    at process (jquery.js?8262:3834:1)
@JamesMcFall JamesMcFall added the Help wanted Person asking for help label Apr 12, 2022
@Soslan24
Copy link

same problem. I don't know how to solve it

@yonchando
Copy link

The same here.

@StenLeinasaar
Copy link

Assuming you included all the dependencies. Here is my approach in a separate js file that I included in my HTML file. It works for me.

"use strict";
var range_slider_custom = {
	init: function () {
			$("#my-slider").ionRangeSlider({
				type: "double",
				skin: "round",
				grid: false,
				min: 0,
				max: 5000,
				keyboard: true,
				hide_min_max: true,
				onChange: function (data) {
					var min = document.getElementById("min_price");
					var max = document.getElementById("max_price");
					min.setAttribute("placeholder", data.from);
					max.setAttribute("placeholder", data.to);
				},
			}),		
	},
};
(function ($) {
	"use strict";
	range_slider_custom.init();
})(jQuery);

I hope that is helpful. Make sure you include all js files in correct order and add them as type="module"

@andreidiaconescu
Copy link

this issue reproduces for me too: i upgraded to angular 15, and bootstrap 5, and i started getting this error:
...ERROR TypeError: this.$(...).ionRangeSlider is not a function

@Yaronberg
Copy link

I encountered a similar problem when I connected jQuery via CDN and imported it into a Vue project at the same time. I recommend checking all jQuery connections in the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Person asking for help
Projects
None yet
Development

No branches or pull requests

7 participants