mxriverlynn / backbone.picky Goto Github PK
View Code? Open in Web Editor NEWselectable entities as mixins for Backbone.Model and Backbone.Collection
selectable entities as mixins for Backbone.Model and Backbone.Collection
Hi Derick,
I have added quite a bit of stuff to Backbone.Picky recently, as you perhaps have noticed. I wanted to have these features around for a project of mine, and thought they might be worth sharing.
That said, I realize that they change the character of your project to some extent. It has been simple and dead easy to adapt; the feature set was minimalistic; reading and understanding every aspect of the code took just a couple of minutes. My additions aren't complex by any means, but still, that kind of simplicity is no longer there.
So I wonder which way things should go. I certainly don't want to swamp you with unwanted PRs. If you'd like to pull the changes, that would certainly be great. But I could just as well turn it into an independent repo of my own, rename it for Bower, and keep the new stuff there. (You'd be credited, of course.)
Either way is fine with me. What are your thoughts?
Cheers,
Michael
It looks like when using Underscore 1.7.0 and Backbone 1.1.2, this plugin breaks. Downgrading to Underscore 1.6.0 fixes the issue.
Hi Derick,
I've currently implemented backbone.picky in a marionette project and overall it's working great. However I have noticed multiple instances in which the 'selected' event is not passing through a model. I can easily get around this by checking if the model is first defined, but it would be nice if the event ALWAYS passes the selected model through.
Eg:
initialize: ->
this.listenTo this.collection, 'selected', (selectedModel) ->
console.log selectedModel // sometimes undefined
The docs for this seem to say it will change a "selected" attribute on the model but it seems to only set a member on that instance instead of in the attributes collection via set
.
On Backbone.Picky.Selectable
:
select: function () {
if (this.selected) { return; }
**this.selected = true;**
this.trigger("selected");
if (this.collection) {
this.collection.select(this);
}
},
Is this intentional? I have to override my view serialization to render to pass this every time, so seems undesirable, but maybe I'm missing something?
Is this so that a change event isn't also fired or something? I guess on a fetch you would lose the selection state as well, but that could be handled.
From the doc:
The Picky collections override the method select on collections. At this point, I can't think of a better name for specifying a model has been selected. Once I find a better name, the API will change.
Instead of select
, has pick
been considered?
It seems to me like pick
is only used on Backbone.Model currently.
the document say it will fire 'select' event. but it indeed fire the selected event. Readme.MD may need to change !
When going old-school with imports in a webpage.
i.e.
<script src="./assets/js/vendor/backbone.picky.js"></script>
<!-- 09.25.2013 minified version broken -->
TypeError: Cannot read property 'SingleSelect' of undefined. w/ minified version of backbone.picky. the normal lib works.
I'm looking in the code after reading the documentation and I can't find deselectAll(). Has there been a change in API?
The doucmentation refers to a deselectAll
function but the code refers to this function as selectNone
It seems that you are the owner of the bower package. I have a problem with it : it installs fine but when I want to use grunt-bower-requirejs, a task that automatically generates the requirejs config file, it gives me an error :
Warning: Ignoring Gruntfile in backbone.picky
You should inform the author to ignore this file in their bower.json
... and backbone-picky is not registred in requirejs-config file.
( Idem for the backbone-syphon package )
I'm building a yeoman generator for marionette based on David Sulk's books. I would really like to generate automatically an out of the box requirejs-config file .
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.