JSmith01/vue-selectable

Problem with rootElement & boundingBox

lgXenos opened this issue · 2 comments

From doc:

/**

  • Event listeners are attached to this element
  • @type {HTMLDocument}
    */
    rootElement = document;
    In my code:
<div  v-selectable="selectableConfig"
...
computed   : {
    selectableConfig() {
         ...
        ret.rootElement = this.$el; // or document.querySelector("#boundingBox");

DOM not ready at this moment. So rootElement have null and error in console

How I can use this option yet?

PS: particulary solved by v-if="isLoaded" and this.$nextTick(_=>{this.isLoaded = true;})


Как их можно передавать в виде HTMLDocument, когда ДОМ еще не готов на момент инициализации? ИМХО: проще там иметь только селекторы. И только в конструкторе заполнять их через querySelector из переданных данных.
А то, что я "отложил" рендер - это жуткий костыль...

Sorry for the big delay, for the question I have no good solution, since this plugin was designed for the application that had never such requirement. Think for the moment your solution is the only workaround possible. Otherwise API of the plugin would need some changes. I'll mark this for myself as the one to think about. Anyways, thanks for report.

PS If you have some suggestions on this, you're welcome :-)

Think I found proper solution for the problem with rootElement - this is described in README now. The idea is to set rootElement to null and set it to correct value later via setOptions call. Since you'll have no event listeners there is no need to worry about boundingBox as well, it can be set together with rootElement.