ai / ai/evil-blocks

Dynamic roles

Aberta
#35 3 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
136
Forks
10
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Hi, @ai !
Is there any way to change roles dynamically? For example, I have table cell with a form inside of it:

``` erb
<%= form_for model.name.downcase, url: adminushka_engine.items_path, method: method, class: 'form-inline', data: { role: 'cell' } do |f| %>
<%= value %>


<% end %>
```

I have triggers to switch between form and value views:

``` coffeescript
evil.block '@@item',
addHiddenFor: (items) -> items.addClass _hiddenClass
removeHiddenFrom: (items) -> items.removeClass _hiddenClass

defaults: ->
@close $ '@@items'
return

open: (cells) ->
@addHiddenFor cells.find '@value'
@removeHiddenFrom cells.find '@form'
cells.data 'role', 'activeCell'
# evil.block.vitalize cells

close: (cells) ->
@addHiddenFor cells.find '@form'
@removeHiddenFrom cells.find '@value'
cells.data 'role', 'cell'
# evil.block.vitalize cells

'click on @cell': (e) ->
@defaults()
@open e.el
return

'click on @cancel': (e) ->
@close e.el.closest '@activeCell'
return
```

After I select form view everything goes ok, but when I try to close form view via `@cancel` button nothing happens. Actually form view had been closed but it was opened again because of `click on @cancel` and `click on @cell` both were triggered by click on `@cancel` button.
I tried to resolve it via change role to `@activeCell` but it was not help.
So what do you think, may be you can suggest me another way to resolve my problem?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.