Giter VIP home page Giter VIP logo

Comments (15)

machineboy2045 avatar machineboy2045 commented on July 3, 2024 1

Why not use a $watch() statement in your angular controller?

from angular-selectize.

PaddyMann avatar PaddyMann commented on July 3, 2024

Here's a better solution that doesn't call onChange twice:

      config.onChange = function(){
        if( !angular.equals(selectize.items, scope.ngModel) )
          scope.$evalAsync(function(){
            var value = angular.copy(selectize.items);
            if (config.maxItems == 1) {
              value = value[0]
            }

            if(modelCtrl.$viewValue != value) {
              modelCtrl.$setViewValue( value );
              scope.config.onChange(value);
            }
          });
      }

from angular-selectize.

PaddyMann avatar PaddyMann commented on July 3, 2024

I could have, but I assumed all of the config options to work and would have saved a couple of hours of headscratching had I known the of the issue :)

I was going to add that adding a $watch to the $digest cycle for each selectize input isn't ideal either, but then I'm unsure how that compares performance-wise with this implementation.

from angular-selectize.

gottfrois avatar gottfrois commented on July 3, 2024

+1 on this, same issue, onChange called twice

from angular-selectize.

donpinkus avatar donpinkus commented on July 3, 2024

+1 also seeing onChance called twice

sounds like we should just watch the model for now

from angular-selectize.

geemang2000 avatar geemang2000 commented on July 3, 2024

+1 onChange does nothing, should expose same events as selectize

from angular-selectize.

geemang2000 avatar geemang2000 commented on July 3, 2024

Nor does onInitialize

from angular-selectize.

geemang2000 avatar geemang2000 commented on July 3, 2024

For what it's worth, the ng-change directive seems to work.

ng-change="change(app.settings)"

from angular-selectize.

miketeix avatar miketeix commented on July 3, 2024

+1 onChange is being called twice

from angular-selectize.

andrewdelprete avatar andrewdelprete commented on July 3, 2024

+1 onChange is being called twice

from angular-selectize.

Uelb avatar Uelb commented on July 3, 2024

+1 onChange is being called twice

from angular-selectize.

andrewdelprete avatar andrewdelprete commented on July 3, 2024

👏

from angular-selectize.

PhiLhoSoft avatar PhiLhoSoft commented on July 3, 2024

As I wrote as comment to your commit (but I feel it belongs more here), I think you still need to set the silent flag to the setValue calls. Not only it prevents unnecessary calls (minor), but it also fixes the double call to onChange in the case of single selection mode.

from angular-selectize.

machineboy2045 avatar machineboy2045 commented on July 3, 2024

I've created a v3 branch that uses the latest version of Selectize:
https://github.com/machineboy2045/angular-selectize/tree/v3.0.0

I was able to simplify the Angular directive a lot. I'd be curious what you
think.

I like the idea of adding support for objects. But I'm worried if we add
functionality that doesn't exist in Selectize itself, then we could diverge
from it so far that we can't take advantage of updates. It would be ideal
if Selectize would add support for objects. But who knows when that would
be.

What if I made an experimental branch? Maybe there could be a better name
for it. And we could add object support to it?

Also, thanks for all your contributions. I know you've been very active
answering questions in the issue pages. :)

On Thu, Aug 6, 2015 at 1:30 AM, Philippe Lhoste [email protected]
wrote:

As I wrote as comment to your commit (but I feel it belongs more here), I
think you still need to set the silent flag to the setValue calls. Not only
it prevents unnecessary calls (minor), but it also fixes the double call to
onChange in the case of single selection mode.


Reply to this email directly or view it on GitHub
#46 (comment)
.

from angular-selectize.

PhiLhoSoft avatar PhiLhoSoft commented on July 3, 2024

Yes, it is nice, it has a cleaner style.
Suggestion: take the opportunity of a new major version number to rename the file from selectize.js to angular-selectize.js, to avoid some confusion (eg. when debugging).

Support for objects: would be nice, I can live without, it just has the overhead of searching the object in the list of options.
Perhaps you can add an angular-selectize specific configuration to enable this.
It is not a major divergence from Selectize, it is just an added feature in the wrapping.

A more risky operation (toward future versions of Selectize) would be to monkey-patch it to fix some issues, like I did in selectize/selectize.js#783
Something that would be useful to have in the wrapper, but currently I just have it in the service wrapping angular-selectize.

from angular-selectize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.