Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

no such method 'setValue' for slider widget instance #57

Open
hmillet opened this issue May 16, 2015 · 18 comments
Open

no such method 'setValue' for slider widget instance #57

hmillet opened this issue May 16, 2015 · 18 comments

Comments

@hmillet
Copy link
Contributor

hmillet commented May 16, 2015

Hi,

I'm trying to use this durective in my application, but no way.
I always have an "no such method 'setValue' for slider widget instance" Error, and my DOM is not like the one in your test page :

<div slider-id="mySlider" ng-model="slider.sliderValue" value="10" min="5" max="100" step="5" range="false" precision="2" reversed="false" orientation="horizontal" handle="round" enabled="true" ng-disabled="false" naturalarrowkeys="false" class="ng-isolate-scope ng-valid">
  <input class="slider-input ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" type="text" aria-disabled="false"></input>
</div>

Has someone an idea on my trouble ?

@seiyria
Copy link
Owner

seiyria commented May 16, 2015

No idea; can you make a plunker that simulates your environment better?

@hmillet
Copy link
Contributor Author

hmillet commented May 16, 2015

Difficult... it's a big app with so many libraries :-(

@seiyria
Copy link
Owner

seiyria commented May 16, 2015

Sorry, without knowing specifically what's going wrong, it's hard to debug an issue.

@hmillet
Copy link
Contributor Author

hmillet commented May 16, 2015

I understand that ... I will still "fight" to understand my trouble... until I can make a plunker

@hmillet
Copy link
Contributor Author

hmillet commented May 17, 2015

I got it.

This does not work when include jquery-ui. That's annoying. Here is my plunker.

http://plnkr.co/edit/hO421vl7G1nHAfCtvclK?p=preview

When you remove the jquery-ui script, all is fine... except that I don't understand why my initial value is not set

Thanks for Help

@hmillet
Copy link
Contributor Author

hmillet commented May 17, 2015

There is an issue about this on the bootstrap-slider project : seiyria/bootstrap-slider#250

An answer was find here for the bootstrap-slider : http://stackoverflow.com/questions/26691018/using-bootstrap-slider-with-jquery-ui

It says : use bootstrapSlider() function in order ti initialize the bootstrap-slider, in replacement of slider()

Maybe this directive can consider this...

@seiyria
Copy link
Owner

seiyria commented May 17, 2015

If you'd like to submit a PR that adds a new attribute no-conflict then I'd take it!

@hmillet
Copy link
Contributor Author

hmillet commented May 17, 2015

What about using the same test than the original bootstrap-slider component, instead of a new no-conflict attribute ?

if($) {
  var namespace = $.fn.slider ? 'bootstrapSlider' : 'slider';
  $.bridget(namespace, Slider);
}

@seiyria
Copy link
Owner

seiyria commented May 17, 2015

That'd be fine also.

@hmillet
Copy link
Contributor Author

hmillet commented May 23, 2015

Well, I can't achieve in making this works.

Adding jQuery-UI, we must use mySlider.bootstrapSlider() instead of mySlider.slider() (information from seiyria/bootstrap-slider)

Replacing then the 6 occurences of slider with bootstrapSlider in the directive script make a new errors occurs, that I cannot understand :

TypeError: Cannot read property 'removeChild' of null
    at Slider.destroy (http://abs.dev.hmillet.com/bower_components/seiyria-bootstrap-slider/js/bootstrap-slider.js:780:31)
    at $.fn.(anonymous function) [as bootstrapSlider] (http://abs.dev.hmillet.com/bower_components/seiyria-bootstrap-slider/js/bootstrap-slider.js:134:50)
    at initSlider (http://abs.dev.hmillet.com/slider.js:113:32)
    at Object.fn (http://abs.dev.hmillet.com/slider.js:187:25)

In the destroy method in bootstrap-slider.js, this.sliderElem.parentNode is null :-(

            destroy: function(){
                // Remove event handlers on slider elements
                this._removeSliderEventHandlers();

                // Remove the slider from the DOM
                this.sliderElem.parentNode.removeChild(this.sliderElem);
                /* Show original <input> element */
                this.element.style.display = "";

                // Clear out custom event bindings
                this._cleanUpEventCallbacksMap();

                // Remove data values
                this.element.removeAttribute("data");

                // Remove JQuery handlers/data
                if($) {
                    this._unbindJQueryEventHandlers();
                    this.$element.removeData('slider');
                }
            },

if someone has any idea...

@seiyria
Copy link
Owner

seiyria commented May 23, 2015

Are you using the right version of the library with the directive?

@hmillet
Copy link
Contributor Author

hmillet commented May 23, 2015

Think so.

Clone the project, run bower install...

@seiyria
Copy link
Owner

seiyria commented May 23, 2015

Just checking. I don't know, it should not matter which function you use. That said, I can't claim to understand how bridget works; it COULD be a byproduct of this library using the jQuery wrapper instead of using the vanilla JS style. Perhaps, the PR would remove the jQuery aspect and instead use that vanilla JS constructor?

@namwkim
Copy link

namwkim commented Jun 9, 2015

The same error occurs in the following (slider.js - line 178):

// deregister ngModel watcher to prevent memory leaks
if (angular.isFunction(ngModelDeregisterFn)) ngModelDeregisterFn();
ngModelDeregisterFn = $scope.$watch('ngModel', function (value) {
slider.slider('setValue', value);
}, true);

@hmillet
Copy link
Contributor Author

hmillet commented Jun 9, 2015

@namwkim : Are you using jQuery-UI ?

@namwkim
Copy link

namwkim commented Jun 9, 2015

Yea I am using jQuery-UI. As far as I know it worked with jQuery-ui before.

I am wondering if this problem occurs with recent updates?.

Here is a working version if you want:
Site: https://study.namwkim.org/bubble/admin#
Source: view-source:https://study.namwkim.org/bubble/admin#

@seiyria
Copy link
Owner

seiyria commented Jun 9, 2015

It's possible that jquery UIs slider is interfering with it, as it has in the past.

@fergalmoran
Copy link

@namwkim The versions you've linked to fix the issue. Where are they from?
Thanks btw!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants