Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can.view and jquery 1.9.0 throws an error #237

Merged
merged 3 commits into from
Jan 25, 2013
Merged

can.view and jquery 1.9.0 throws an error #237

merged 3 commits into from
Jan 25, 2013

Conversation

daffl
Copy link
Contributor

@daffl daffl commented Jan 25, 2013

The following line raises an error :

can.view("player-template", {playlist:{name:"xx","id":1}, name:"ddd",  song:null})

An error :
Uncaught TypeError: Object [object Object] has no method 'createDocumentFragment'

A template:

<script type="text/ejs" id="player-template">
<div id="player" class="container">
    <div class="navbar">
      <div class="navbar-inner">
        <div class="container">
                <ul class="nav pull-right player-controls">
                  <li class="name"><div class="song-progress"></div><span class="playlist"><%= playlist.name %></span> <span class="song"><% if(song){ %><% song.Album.Artist.name %> - <%= song.Song.name %><% } %></span></li>
                  <li class="play"><a class="btn" href="javascript://" ><i class="icon-play"></i> Play</a></li>
                  <li class="pause"><a class="btn" href="javascript://" ><i class="icon-pause"></i> Pause</a></li>
                  <li class="next-song"><a class="btn" href="javascript://"><i class="icon-forward"></i> Next Song</a></li>
                  <li class="volume"><div class="volume-control hide"><div class="volume-slider-vertical" ></div></div><a class="btn" href="javascript://"><i class="icon-volume-up"></i></a>
                  <li class="volume-off"><a class="btn" href="javascript://"><i class="icon-volume-off"></i></a>
                  <li class="like"><a class="btn" href="javascript://"><i class="icon-thumbs-up"></i></a>
                  <li class="dislike"><a class="btn" href="javascript://"><i class="icon-thumbs-down"></i></a>
                  <li class="share"><a class="btn" href="javascript://"><i class="icon-share"></i> Share</a>
                </ul>
            </div>
        </div>
    </div>
</div>
</script>

@ghost ghost assigned daffl Jan 17, 2013
@daffl
Copy link
Contributor

daffl commented Jan 17, 2013

Yes, CanJS currently doesn't work with jQuery 1.9. They've done some weird changes working with document fragments. We'll try and make it work with the 1.1.4 release.

@aloise
Copy link
Author

aloise commented Jan 17, 2013

I see. Thank you !

@rjgotten
Copy link

We'll try and make it work with the 1.1.4 release.

Not sure how far along you are for a solution, but FYI; you should simply be using the new jQuery.parseHtml function to parse HTML strings into jQuery-wrapped DOM element collections.

Should you really need document fragments instead of element collections, then you can use the following trick:

var node = jQuery.parseHtml( html )[0];
var fragment = node && node.parentNode;
return fragment;

jQuery has a unit test in place which guarantees that the parentNode of the elements in the collection returned by jQuery.parseHtml is a document fragment.

@ghost ghost assigned amcdnl Jan 18, 2013
@ghost ghost assigned daffl Jan 25, 2013
daffl added a commit that referenced this pull request Jan 25, 2013
@daffl daffl merged commit 279583b into master Jan 25, 2013
@daffl daffl deleted the jquery-1.9.0 branch January 25, 2013 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants