> Le 16 avr. 2015 à 23:32, Terrence Brannon <metap...@gmail.com> a écrit :
> 
> I'm continuing my implementation of TodoMVC:
> http://todomvc.com/examples/react/#/
> 
> When a todo item is checked, it is supposed to be marked as
> "completed" in the model. The text of the todo is supposed to be
> struck-through. 
> 
> So:
> 1. Clicking the checkbox should change the editor value and a commit
> should occur to alter the actual model value. I'm attempting to do
> this on line 83:
> https://gist.github.com/metaperl/e6fd793736f12656cd8b#file-gistfile1-py-L83
> but the problem is I don't know how to set the value attribute for the
> input type of checkbox so that it gets passed to .action() 
> as the docs discuss under "Form elements" here:
> http://www.nagare.org/trac/wiki/CallbacksAndForms
> 
> I think it should be a method something like:
> class TodoEntry(object):
>     def commit_completed(self, completed_value):
>         self.completed(completed_value)
>         self.commit()
> 
> and the action would simply be a callack like 
>   .action(todo_item.commit_completed)

Line #81 you are creating a new sub-form for each item.

I changed it by a 'with h.div:' and added a submit button line #91 in
  https://gist.github.com/metaperl/e6fd793736f12656cd8b#comment-1437980

> 2. Clicking the checkbox should also alter the CSS so that the text of
> that Todo is rendered with "'text-decoration': line-through"
> 
> I'm attempting this on line 84:
> https://gist.github.com/metaperl/e6fd793736f12656cd8b#file-gistfile1-py-L84

As 'text-decoration' is not an attribute but a style, the line:

  h.span({ 'text-decoration': 'line-through' })

must be changed by:

  h.span(style='text-decoration: line-through')

> but 
> (a) I dont like the repetition of the code `h << todo_item.text()` 
> and want to find a way to only write that line once

You can change the lines:

  if todo_item.completed():
      with h.span(style='text-decoration: line-through'):
          h << todo_item.text()
  else:
      h << todo_item.text()

by something like:

  text_style = 'line-through' if todo_item.completed() else 'none'
  h << h.span(todo_item.text(), style='text-decoration:' + text_style)

> (b) The text is not being struck-through even when the button is clicked.

See above

> I'm also noticing that the GuestBook example in
> http://www.nagare.org/trac/wiki/CallbacksAndForms is doing what I am
> doing without creating 2 different components.

Right.


Also you don’t need to define 'editor.Editor' sub-classes. Here is a simpler
example without theses classes:
  https://gist.github.com/nagareproject/3984ff9d13616f85b908 


Then you can change the checkboxes action to be an 'ajax.Update()' if you want
it to be executed as soon as the checkbox is clicked:
  https://gist.github.com/nagareproject/6ea5eebffa93b199afde

-- 
You received this message because you are subscribed to the Google Groups 
"Nagare users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nagare-users+unsubscr...@googlegroups.com.
To post to this group, send email to nagare-users@googlegroups.com.
Visit this group at http://groups.google.com/group/nagare-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to