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

select editor does not fetch collection if given with function callback (FIX) #457

Open
mdimitr opened this issue Mar 16, 2015 · 0 comments

Comments

@mdimitr
Copy link

mdimitr commented Mar 16, 2015

I needed to make my select box dynamic based on a backbone collection (whenever created to use updated collection), for this reason instead of providing the collection directly I used the function callback feature.
In such a way:

myfield:{
type: 'Select' ,options : function(callback, editor) {callback(myApp.getCollection(collectionName,CollectionClass))}
},

the getCollection function retrieves a collection from global scope, or creates it if it does not exist, but does not fetch it.

If the collection was not previously fetched (is still empty) the select editor would not fetch it.

To fix that i edited the setOptions function in editors/select.js to call itself if function found in order to handle a returned collection.

FIX:

    //when function is passed in setOptions function in editors/select.js line 71
    else if (_.isFunction(options)) {
      options(function(result) {
        self.setOptions(result);    // FIX call self in order to handle collections or even another function
       }, self);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant