jeudi 24 mars 2016

Append emberjs component to dom in route

I'm dynamically creating an ember component with an ember route and need to append this component into the DOM. I do so like this:

createwidget : function (row, column, value, htmlElement) {
                var componentObj = {};
                componentObj.props = {
                                        id: 'selectid', 
                                        content: $this.codes, 
                                        optionValuePath: 'code', 
                                        optionLabelPath: 'value', 
                                        selectedValue: '', 
                                        name: 'selectInputName', 
                                        selectedLabel: '', 
                                        dropdownLabel: 'selectLabel', 
                                        placeholder: 'selectPlaceholder'
                                    };
                componentObj.name = 'jpma-select';
                componentObj.type = 'component';
                var component = $this._createComponent(componentObj);
                component.appendTo($(htmlElement));
            }

createwidget is function that comes from the jqxgrid widget. It allows you to dynamically create elements and add them to a grid cell. _createComponent is one of our custom methods that creates a custom ember component, in this case a select. I get the error: "Assertion Failed: You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead."

If I wrap the component as a jQuery object, like this: $(component).appendTo($(htmlElement));

I get this error: "jpma-analytics-tracker.js:154 TypeError: Cannot read property 'ownerDocument' of undefined(…)"

So what gives? What can I do to make this work? Thanks




Aucun commentaire:

Enregistrer un commentaire