can.view() stops working when execute three times with can.jquery #33

Closed
verto opened this Issue Apr 17, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@verto

verto commented Apr 17, 2012

Scenario:

<script type="text/ejs" id="content"><form><button class="cancel">cancel</button></form></script>

<div id="form"></div>

<script type="text/javascript">
  function call() { 
   $('#form').html(can.view('content'));
}
</script>
<a href="javascript:call()">execute</a>

click three times on execute link.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Apr 18, 2012

Contributor

which version of jQuery are you using?

Contributor

justinbmeyer commented Apr 18, 2012

which version of jQuery are you using?

@verto

This comment has been minimized.

Show comment
Hide comment
@verto

verto Apr 18, 2012

v1.7. 2

Sent from my Nexus S
On Apr 17, 2012 11:10 PM, "Justin Meyer" <
reply@reply.github.com>
wrote:

which version of jQuery are you using?


Reply to this email directly or view it on GitHub:
#33 (comment)

verto commented Apr 18, 2012

v1.7. 2

Sent from my Nexus S
On Apr 17, 2012 11:10 PM, "Justin Meyer" <
reply@reply.github.com>
wrote:

which version of jQuery are you using?


Reply to this email directly or view it on GitHub:
#33 (comment)

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Apr 18, 2012

Contributor

I have verified this is an error. It seems jQuery's buildFragment returns a cacheable flag and it's up to jQuery to clone it when appropriate. For example:

ret = jQuery.buildFragment( [ match[1] ], [ doc ] )
( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment )

This means that jQuery's buildFragment is not something we should follow exactly. We need our own which always returns a fresh copy.

Here's a JSFiddle that shows the problem: http://jsfiddle.net/7ACEL/2/

Contributor

justinbmeyer commented Apr 18, 2012

I have verified this is an error. It seems jQuery's buildFragment returns a cacheable flag and it's up to jQuery to clone it when appropriate. For example:

ret = jQuery.buildFragment( [ match[1] ], [ doc ] )
( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment )

This means that jQuery's buildFragment is not something we should follow exactly. We need our own which always returns a fresh copy.

Here's a JSFiddle that shows the problem: http://jsfiddle.net/7ACEL/2/

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Apr 18, 2012

Contributor

I'll have a fix for this sometime today.

Contributor

justinbmeyer commented Apr 18, 2012

I'll have a fix for this sometime today.

@verto

This comment has been minimized.

Show comment
Hide comment
@verto

verto Apr 18, 2012

Cool! Thanks.

Sent from my Nexus S
On Apr 17, 2012 11:25 PM, "Justin Meyer" <
reply@reply.github.com>
wrote:

I'll have a fix for this sometime today.


Reply to this email directly or view it on GitHub:
#33 (comment)

verto commented Apr 18, 2012

Cool! Thanks.

Sent from my Nexus S
On Apr 17, 2012 11:25 PM, "Justin Meyer" <
reply@reply.github.com>
wrote:

I'll have a fix for this sometime today.


Reply to this email directly or view it on GitHub:
#33 (comment)

thecountofzero pushed a commit to thecountofzero/canjs that referenced this issue Jun 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment