Uncaught TypeError: Cannot read property 'replace' of undefined

edited January 31 in Technical questions

I have in my code a basic Kanban with "comments: true" and I'm populating the kanban from a php file that outputs the following xml:

<data>
<item id="1614"/>
<status>CNF</status>
<user_id/>
<text>James</text>
<tags/>
<color>1</color>
<email>James@mail.com</email>
<phone/>
<comments>
[{id:1, date:2019-01-28 18:33:05, text:Is it ready}]
</comments>
<comments>
[{id:1, date:2019-01-28 18:33:05, text:Is it ready}, {id:2, date:2019-01-28 18:33:19, text:Not yet}]
</comments>
</item>
</data>

The kanban is populated with the above data and comments icon shows 2 comments, but when I click on it, the comment widget opens with no comments and the console shows the following error:

Uncaught TypeError: Cannot read property 'replace' of undefined

What am I doing wrong? Also is it a problem that comments id:1 is showing twice?
Thanks,
Brian

Tagged:

Comments

  • It seems that you are mixing JSON and XML data
    With such a code, the kanban will read comments data as string instead of objects, and as result will not be able to get any further properties.

    The default format of data for kanban is the JSON

    You can use XML, but it means that all values inside of data must be encoded as XML.

  • edited January 31

    Thanks Maksim,

    I've tried encoding as xml as follows:
    <data>
    <item>...
    <comments><id></id><date></date><text></text></comments>
    </item>
    </data>

    and still get the same error message. Do you have a example of the correct xml format?'
    Thanks,
    Brian

  • Hi Nastja,

    I am following the xml schema properly and can load the kanban with xml, but the problem is trying to add comments with xml.

    Do you have an xml example that includes comments tag or can provide some guidance for including comments?

    Thanks,
    Brian

  • Could you please clarify why do you use xml instead of JSON?
    JSON is easier to implement

  • edited February 1

    Please, try the following snippet: https://snippet.webix.com/8v6af0xk

    The trick does the stack property as an attribute of a comments tag, which indicates an array of comment items:

    <comments stack="1"><item text="try it"/></comments>

  • Perfect. Thank you Helga!

    Nastja, just my preference.

    Thank you all for the assistance!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!