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

optionTemplate and optionView not working anymore #29

Closed
saarangsoltani opened this issue Feb 22, 2015 · 15 comments
Closed

optionTemplate and optionView not working anymore #29

saarangsoltani opened this issue Feb 22, 2015 · 15 comments

Comments

@saarangsoltani
Copy link

optionTemplate,itemTemplate,optionCreateTemplate,optgroupHeaderTemplate,optgroupTemplate, optionView,itemView,optionCreateView,optgroupHeaderView and optgroupView

basically using the above-mentioned properties would cause ember throw an error saying view.renderToBuffer() is no longer available. we should find a workaround for this. Maybe get the string representation of rendered view this way:

      _getStringFromView:function(view){
           view.createElement();
           return view.element.outerHTML
      },

i can get it done if you want

@salzhrani
Copy link
Contributor

I suggest using the function variants, currently rendering templates and views in an ad hoc manner is not exposed in a public API.

@saarangsoltani
Copy link
Author

well createElement() is part of the public API : http://emberjs.com/api/classes/Ember.View.html#method_createElement

@salzhrani
Copy link
Contributor

the last two paragraphs. But Even if you get it running all you get back is the html of the view and not any behaviours attached to the view, so it could be less efficient. you can try if you like.

@netcurate
Copy link

Well, there is another issue with function variants. Check this out.

{{ember-selectize
content=controller.items
optionValuePath="content.id"
optionLabelPath="content.selectize_display"
sortField= "display_name"
optionFunction=controller.offn
itemFunction=controller.itmf
}}

Now in controller, you have this:

offn: function(i){

    if (!Ember.isEmpty(i.label)){
        return i.label.toHTML();
    }
},
itmf: function(i){
    if (!Ember.isEmpty(i.label)) {
        return i.label.toHTML();
    }
},

So far all is ok. As you can see content is binded to controller.items ... but if this items is changed and you come back second time, the functions do not pick up the added items.

I tried making these properties dependent on items, but that means when a new item is added offn and itmf gets called and they do not have values for "i" parameter.

What is wrong here?

@miguelcobain
Copy link
Owner

If only selectize could support DOM nodes... : selectize/selectize.js#617

@miguelcobain
Copy link
Owner

New progress, maybe: emberjs/ember.js#5534 (comment)

@saarangsoltani
Copy link
Author

@miguelcobain seems like DOM nodes are now supported ? that pull-request is merged

@miguelcobain
Copy link
Owner

Looks like its still open: selectize/selectize.js#617

@abhilashlr
Copy link

Is it possible to render component inside the itemFunction?

{{some-component text='Lorem'}}

@Ramblurr
Copy link

Rendering a component inside the itemFunction is exactly what I'm looking for, that or using itemView and passing a component, however that doesn't seem to be working right now.

Any tips on rendering a component from itemFunction?

@topaxi
Copy link

topaxi commented Jan 4, 2016

The PR to allow DOM nodes was successfully merged yesterday 👍

@miguelcobain
Copy link
Owner

I was watching that thread. Great news!
In theory, we can now:

  • make ember-cli-selectize install selectize master from bower (not master branch, but a fixed sha, of course)
  • lookup a component/template and pass selectize the rendered DOM

I accept PR's and can offer some guidance at ember's slack, if needed.

@miguelcobain
Copy link
Owner

Closed by 47bfcaa

Latest Selectize bower version doesn't include @topaxi's PR yet. Currently using my fork of selectize. Will change to selectize's when it bumps.

@Ramblurr
Copy link

Awesome news!

Just curious, does this fully support component in the ember way? That is, with actions and computed properties? Or is it a one-time rendering of a component?

@miguelcobain
Copy link
Owner

Yes. Normal components. Bindings, actions, everything.

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

7 participants