0

I am trying to change the nodes' text-valign property from 'bottom' to 'top' after the initialisation with the following code:

cy.$('#j').style({'text-valign': 'top'});

However when I run this code its only go up some pixels instead to the top of the node, but as soon as I click to that node, it goes to the correct position. What function should I call to solve this problem?

UPDATE

I temporarily solved the problem with a function that causes redraw (I did not have much time, could not think of another solution):

cy.$('#'+nodeid).style({'text-valign': place}); 

if (cy.$('#'+nodeid).hasClass('solution'))
    cy.$('#'+nodeid).removeClass('solution'); 
else 
    cy.$('#'+nodeid).addClass('solution')

Regards, Oliver

rasekoli
  • 87
  • 1
  • 9

1 Answers1

0

You shouldn't be using a .style() bypass in general. It's for exceptional cases, just like you wouldn't set all of your CSS in the style attribute of a DOM element.

Either add a class that has the desired style to the element or use a function as the value for the style property.

maxkfranz
  • 11,896
  • 1
  • 27
  • 36