inesita-rb / inesita

Frontend web application framework in Ruby using Opal.
https://inesita.fazibear.me/
MIT License
259 stars 15 forks source link

style.visibility = 'hidden' overkills other elements #12

Closed olegantonyan closed 8 years ago

olegantonyan commented 8 years ago

Probably a bug in opal/opal-browser I have a button which should be hidden in same cases:

def after_render
  update_add_button_visibility
end

def update_add_button_visibility
  $document['button-add-selected'].style.visibility = selected_items.empty? ? 'hidden' : ''
end

It works, but along with right id (button-add-selected) other elements also gets hidden.

My playground repository https://bitbucket.org/antlabs_dev/rmpd_server_frontend open playlists in navbar and check left list of the items. This is MediaItems::Index component.

What I see is that first element in a list always disappear, sometimes first and second. If you inspect the page with inspector you'll find that for these elements visibility is hidden. If you remove $document['button-add-selected'].style.visibility = selected_items.empty? ? 'hidden' : '' than it works as expected

`document.getElementById("button-add-selected").style.visibility = "hidden"`

gives same result

fazibear commented 8 years ago

With Inesita, you're playing with virtual-dom, don't afraid to remove item and rerender whole screen. You should not use after_render and all this jquery like stuff.

Store should keep your application state. Render methods should depend on state, and all actions should change state and call render!.

You should read about flux application architecture.

olegantonyan commented 8 years ago

Ok, thanks! Sorry for the stupid questions