question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

From what context to get select options source?

See original GitHub issue

Hi, i’m hoping to transfer from backbone.stickit to backbone.epoxy. Mostly epoxy seems better to our needs. But i’m trying to get a <select> filled.

in stickit i would do:

    bindings:{   
         '#category': {
                observe: 'category_id',
                selectOptions: {
                    collection: function(){
                        return this.App.request('collection', 'frontofficemenu');
                    },
                    labelPath: 'name',
                    valuePath: 'id'
                }
            }
      }

the this.App.request returns a collection i’d like to use. Is there some way to do this in epoxy, including the labelPath and valuePath options set per view? maybe through a custom handler?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
maxpoulin64commented, Jul 1, 2014

Is there anything preventing you from creating and fetching your map and then just pass the resulting collection to Epoxy? Like this:

// Somewhere before your .extend()
var MAP = new FoMenuMap(); MAP.fetch();

// ....
    bindingSources: {
        categories: MAP
    },
    bindings: {
        '#category':'options:$categories'
    }

That way you only ever have one instance of the collection, it’s already fetched and everything. Don’t worry about it being loaded or not, all Epoxy views bound to it will instantly refresh as soon as it will be done fetching.

Also, i think it would really really be helpfull in some ways to be able to define labelPath and valuePath in the specific binding.

Totally agreed, but I’m not sure if it can be implemented in the current state. The way optionsDefault and optionEmpty work is already a bit hackish (they are hardcoded exceptions to the regular handlers map). I have no idea if the author is planning on making that possible or not. Maybe there’s a way to change options: to accept an hash instead so we can so stuff like options:{collection:$myOptions,label:'myNameField',value:'id'} like events: does.

0reactions
patrick-radiuscommented, Jul 1, 2014

@maxpoulin64 yes {options:$myOptions,label:'myNameField',value:'id'} this would be awesome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<select>: The HTML Select element - HTML - MDN Web Docs
Each <option> element should have a value attribute containing the data value to submit to the server when that option is selected.
Read more >
jQuery Get Selected Option From Dropdown - Stack Overflow
If you are in event context, in jQuery, you can retrieve the selected option element using : $(this).find('option:selected') like this :
Read more >
SuiteScript 2.x: Suitelet > Select field that sources the options ...
In a suitelet, there is a method called formField.addSelectOption that allows you to set the static select options for the select field.
Read more >
How to get Select Options in Template from Attribute Source ...
I created all the needed files but i don't know how to get the options (created in source model) in the template file....
Read more >
Options picker - Budibase Docs
First, select. Data Provider as the options source in the Settings Panel. 512. Next, there are 3 selections to be made in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found