arguiot/DisplayJS

$.live() may be has some problems.

Closed this issue · 3 comments

I don't know hou to descripe in English...

使用dog初始化,然后使用 $.var(true) 进行绑定。
但是当我修改dog中的变量的值的时候,视图并没有立即刷新,当我第二次修改才会刷新。

Translate by Google:

Use dog to initialize, and then use $ .var (true) for binding. But when I modify the value of the variable in dog, the view does not immediately refresh, when my second change will refresh.

Maybe the gif can let you know what i said.

live-problem github

Here is the code:

<p>My dog's name is <span var="name"></span></p>
<p>It is <span var="age"></span> years old now!</p>

&

var dog = {
    name: 'doge',
    age: 12
}
var $ = new DisplayJS(dog)
$.var(!0)

i hope you can understand what i mean.

Ok, so of what I understand, when you change the dog variable, the $.live() function is taking one change before the last one. Tell me if I’m right 😊. But, just another question, why are you using $.var(!0) instead of $.var(true)?

Almost the same meaning.
!0 === true and !1 === false , Do not you think it's so cool?

@JZLeung Yeah, it's cool 😎, I didn't know that. But, I already noticed this, but I don't have any current solution for that if you have one, you can do a PR, and If it works, I'll accept 😊.