coffeescriptspine.js

Prevent creating DOM element in the controller and use view instead


As you may know Spine controllers create their DOM elements ( <div> by default ). How could we prevent creating such elements and use only markup in the view?

I read the documentation but didn't find any information.


Solution

  • The relevant line is https://github.com/spine/spine/blob/dev/src/spine.coffee#L488, which says:

    @el  = document.createElement(@tag) unless @el
    

    In order to avoid having the element be created, you can pass in an el to the constructor. Alternatively, you can call @replace() in your render method to replace the div with your own element.