Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Why does this ultra simple html generate an error ?

$
0
0
Justin

Thanks for your response. I can't remember where I did the initial download but never mind. Unfortunately we are still not there.

Using jquery 1.7.2 and all the can 1.1.5 downloads and referring to your online documentation and examples I find the following :

1. The syntax `can.view(templateId, context)` *DOES NOT WORK*
===================================================

Assuming that context is a simple Javascript object (not an observable etc) then :

The construct `$el.append(can.view(templateId, context))` raises a jquery error relating to document fragments. Not surprisingly it's more informative to use jquery.js rather than jquery.min.js.

The error arises from the can.view(templateId, context) part.

The following syntax *DOES* work with said simple Javascript object :

      template = can.view(templateId);       // compile the template
      $el.append(template(context))           // render it

Using this syntax allows a handlebars template to be correctly rendered but with *NO BINDING* as there is no can.Observe in use.

2. The examples at http://donejs.com/docs.html#!Acquisition *DO NOT WORK*
============================================================

The first example shows a template creation using raw text, however, as shown it fails.

The `can.view.frag(fragment)` throws an error, and as fragment is *already* a correctly rendered string it should be rendered to the DOM as

      `can.$(document.body).append(fragment)`

3. The one way binding example documented at http://donejs.com/docs.html#!Binding *DOES NOT WORK*
=================================================================================

This example purports to show a one way binding of a can.Observable to a handlebars template

It suffers from the above problem. If it is amended as above to first compile, then render, then it outputs the following :

Welcome @@!!@@
@@!!@@

Which seems to be the skeleton of the template prior to the expected substitutions

4. The jsfiddle at http://bitovi.com/blog/2012/12/canjs-1.1-release-notes.html *DOES NOT WORK*
==========================================================================

Pressing the Annotate for Can results in a runtime error, essentially the same error as (1) (we are using jquery.min so slight difference)

Conclusion
=========

I am so far unable to find any way whatever of rendering a can.Observe to a handlebars template, with or without a working binding.

Getting one's head around a new piece of technology is often a challenge, but when the documented examples and instructions are *patently wrong* then it becomes an exercise in futility.

Please get this fixed / documentation amended / whatever, it's an absolute show stopper and I cannot be the only user facing (or about to face) this problem.

Regards

Ron



Viewing all articles
Browse latest Browse all 3491

Trending Articles