1

Getting an errror

Uncaught ReferenceError: Unable to parse bindings.
Bindings value: html: typeof rowText == 'function' ? rowText($parent) : $parent[rowText] , attr: {class: [rowText]}
Message: $parent is not defined

on

    <tbody data-bind=\"foreach: itemsOnCurrentPage\">\
         <tr data-bind=\"foreach: $parent.columns, attr: {id: ItemId},css:{even:$index()%2==0,odd:$index()%2!=0}\">\
             <span data-bind=\"html: typeof rowText == 'function' ? rowText($parent) : $parent[rowText] , attr: {class: [rowText]}\"></span>\
          </tr>\
     </tbody>\

when the span is replaced with the td tag, it works fine.

    <tbody data-bind=\"foreach: itemsOnCurrentPage\">\
         <tr data-bind=\"foreach: $parent.columns, attr: {id: ItemId},css:{even:$index()%2==0,odd:$index()%2!=0}\">\
             <td data-bind=\"html: typeof rowText == 'function' ? rowText($parent) : $parent[rowText] , attr: {class: [rowText]}\"></td>\
          </tr>\
     </tbody>\

I need span tag over there somehow. Can, anybody please tell me, why it shows error while binding if used span instaed of td tags. Here is a example http://jsfiddle.net/pratbhoir/fNhKp/10/

1
  • Can you show your viewmodel code?
    – Akhlesh
    Mar 18, 2014 at 10:41

1 Answer 1

2

You can not have span directly under 'tr' it must be inside td and that is why you are getting error. so put span under td.

 <tbody data-bind="foreach: itemsOnCurrentPage">
    <tr data-bind="foreach: $parent.columns">
           <!--ko ifnot: typeof rowText == 'object' && typeof rowText.action == 'function'-->
          <td> 
            <span data-bind="text: typeof rowText == 'function' ? rowText($parent) : $parent[rowText] "></span>
         </td>
        <!--/ko-->
     </tr>
  </tbody>

Error

There are limited elements that are valid children of the HTML table element, these are:

  • colgroup,
  • thead,
  • tfoot,
  • tbody, and
  • tr

so when you will try to validate html with invalid span tag inside tr tag it will give error like:-

 Start tag span seen in table.//error invalid html

http://jsfiddle.net/fNhKp/11/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.