Background image link by data array

独自空忆成欢 提交于 2019-12-12 02:24:49

问题


I get this error in cytoscape.js:

"Do not assign mappings to elements without corresponding data (e.g. ele p for property background-image with data field linkImagem); try a [linkImagem] selector to limit scope to elements with linkImagem defined"

Look data array:

{ data: { id: 'atr1', classificacao : '1', backgroundColor : '#F79646', nomeAtributo : 'Bancos desconfortáveis', angulo : '0', valign : 'top', halign : 'right', linkImagem : 'http://www.fec.unicamp.br/~confterm/imagens/background/nodes/8.png' }, position: { x:220, y: 300 }, selected: false, selectable: false, locked: false, grabbable: false }

Look script style options:

.selector('node')
          .css({
            'label': 'data(nomeAtributo)',
            'text-valign': 'data(valign)',
        'text-halign': 'data(halign)',
            'color' : '#000',
            'font-size': '11px',
            'background-fit': 'fit',
            'background-color': 'data(backgroundColor)',
            'background-image': 'data(linkImagem)',
          })

How I can solve this?


回答1:


The solution is given to you in the error message. Either don't use mappers if you're not going to define the data for each matching element, or adjust your selectors so that they only match elements with the data defined.



来源:https://stackoverflow.com/questions/33927020/background-image-link-by-data-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!