Comments (15)
Why not use a $watch() statement in your angular controller?
from angular-selectize.
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.
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.
+1 on this, same issue, onChange called twice
from angular-selectize.
+1 also seeing onChance called twice
sounds like we should just watch the model for now
from angular-selectize.
+1 onChange does nothing, should expose same events as selectize
from angular-selectize.
Nor does onInitialize
from angular-selectize.
For what it's worth, the ng-change directive seems to work.
ng-change="change(app.settings)"
from angular-selectize.
+1 onChange is being called twice
from angular-selectize.
+1 onChange is being called twice
from angular-selectize.
+1 onChange is being called twice
from angular-selectize.
👏
from angular-selectize.
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.
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.
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)
- Allow-Clear Option to Clear the selected value
- Restrict enter key to select the options HOT 1
- NPM repo is out of date HOT 2
- How do I select an item programatically? HOT 1
- can't include in entry webpack file....
- Angular missing as dependency in bower.json
- performance ui-select vs angular-selectize demo
- Impossible to select value in angular 1.6.4 HOT 5
- Is there a way to change maxItems value based on user activity? HOT 1
- Two dataway binding does not respect order - Regular select dropdown does HOT 2
- Angular selectize directive - I can't type in input when I select empty option
- selecting data from list and while reomving it doesnot save data on save button angularjs
- Allow edit mode for selected option HOT 1
- Handle large amount of data HOT 1
- selectize does not load
- Selectize does not seem to work in IE11 with older angular versions HOT 3
- Verision 3.0.2 does not have a release in Github HOT 1
- Input styles
- Label field going thru $sce.trustAsHtml() ? HOT 1
- When selectize-input is focused and i click on it - the Dropdown close and open every click. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-selectize.