question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected token u in JSON at position 0 when using directives and sorting items

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior When you drag & drops an item into an item, everything is fine, also when you drags the dropped item back into the place which has no children, but when you drag & drops an item between two items, so not into an item, I get the following error Unexpected token u in JSON at position 0

Sidenote: when I log ‘orderableList’ into my controller, I get the originally list, not the one which is shown, how can I get this?

Expected behavior Drag & drop items into an item + drag & drop item between items should behave correctly

Reproduction of the problem

<div class="ngx-dnd-container"
         ngxDroppable [model]="orderableList" #wtftest>
      <div class="sensor-big-container has-handle"
           ngxDraggable ngxDroppable (drop)="onDropSuccess($event)"
           *ngFor="let sensorGroup of orderableList" fxLayoutGap="14px" [model]="sensor" style="border:1px solid red">
        <div fxFlex class="sensor-container" *ngFor="let sensor of sensorGroup.children" fxLayoutGap="14px">
          <mat-icon svgIcon="sensor"></mat-icon>
          <span fxFlex>{{sensor.name}}</span>
          <mat-icon ngxDragHandle class="draghandle" svgIcon="draghandle"></mat-icon>
        </div>

      </div>
    </div>
this.orderableList = map(this.sensors, ((sensor: MonitorSensor) => {
      return {label: '', children: [sensor]}
    }));

What is the motivation / use case for changing the behavior? needs to drag an item and drop into it as well

Please tell us about your environment: OSX

  • Angular version: 5.1.1

  • Browser: [all]

  • Language: [ TypeScript 2.6.2 ]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Hypercubedcommented, Jan 21, 2018

@elineopsommer Darn, looks like the plunker didn’t get saved correctly. I had to redo it… again, notice that the each droppable and draggable has a [model].

https://embed.plnkr.co/FH9gGy/

0reactions
CodingGorillacommented, Mar 13, 2018

This seems to be pointed to as a sort of documentation by example issue, however this plunker does not work for me. Can the plunker be fixed, or is there some other way to host or view this example?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix Unexpected token u in JSON at position 0
This error is caused when you are attempting to parse a non-existent property. Typically, this is due to a misspelling, or simply referencing ......
Read more >
Uncaught SyntaxError: Unexpected token u in JSON at ...
Your app is attempting to parse the undefined JSON web token. Such malfunction may occur due to the wrong usage of ...
Read more >
Unexpected token u in JSON at position 0 Error in JS
The "Unexpected token u in JSON at position 0" error occurs when we pass an undefined value to the JSON.parse or $.parseJSON methods....
Read more >
'Unexpected token < in JSON at position 0' when enrolling ...
This error occurs when a Moodle page makes a background request to the server using XHR (sometimes called AJAX). The Moodle page expects...
Read more >
uncaught syntaxerror: unexpected token '<', <!doctype ... is ...
It's not ideal to return HTML when you pass an Accept header for json, but errors generally aren't ideal in the first place....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found