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.

After calling remove_all_widgets, then adding more widgets, I can't drag a widget where an old widget once was.

See original GitHub issue

After calling remove_all_widgets(), then adding more widgets, I can’t drag a widget where an old widget once was.

For example, if I create a grid with 2 rows and 3 columns like so:

+-----+-----+----+
|  1  | 2  |  3 | 
+-----+-----+----+
|  4  | 5  |  6 | 
+-----+-----+----+

Then call remove_all_widgets(), then recreate the same grid as above, I can’t drag any widget onto another widget without getting the below errors (multiple times):

Uncaught TypeError: Cannot read property ‘row’ of undefined

I can however, move a widget below into, say “the third row”, onto 7, 8, and 9.

Thanks in advance for any help.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
parliament718commented, Mar 15, 2016

@sniperwolfpk5 thanks for posting the fix. $('.gridster ul').empty() sufficed for me. The following “cleanup routine” seems to work the best:

gridster.remove_all_widgets();
gridster.destroy();
$('.gridster ul').empty();
0reactions
jvelezccommented, May 16, 2016

1+ please fix it on the underlying library with @OscarEriksen fix.

If you invoke removeWidget(“#something”); Then right after invoke removeWidget(“#somethingelse”);

Then you try to add_widget(“#something”); You get the same error.

My work around:


  let svc = new GridSterService(); //TypeScript class I will not bore you with details but it gives me 
//the a gridster instance. 
  $('#vrxAddOpenPanel').click(() => {
            if (!$("#openPanel").length) {
                createOpenPanelWidget(svc);
                //Because there something broken with gridster I choose to invoke a jquery click event
                //https://github.com/ducksboard/gridster.js/issues/271
                //Which circumvents the issue all together.
                $("#vrxAddWelcomeMessageWidget").trigger("click");
            }
        });

Which triggers a jquery event to actually handle things properly instead of the javascript nonsense exception.


  $('#vrxAddWelcomeMessageWidget').click(() => {

            if (!$("#welcomeMessageWidget").length) {

                createWelcomeMessage(svc);
            }
        });

and to remove.

 $('#vrxRemoveOpenPanel').click((element: HTMLElement) => {
            if ($("#openPanelWidget").length) {
                svc.removeWidget($("#openPanelWidget"));

                $("#vrxRemovedWelcomeMessageWidget").trigger("click");
            }


        });
  $('#vrxRemovedWelcomeMessageWidget').click(() => {
            if ($("#welcomeMessageWidget").length) {
                svc.removeWidget($("#welcomeMessageWidget"));
            }
        });

Nasty but works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add, modify, or remove widgets from Android
Locate the widget you want to modify, and then tap and hold it. You can now either reposition it by dragging and dropping...
Read more >
Add widgets on iPhone - Apple Support
Go to the Home Screen page where you want to add the widget, then touch and hold the Home Screen background until the...
Read more >
Add or remove apps or widgets on the home screen of your ...
When you're done editing, tap anywhere outside the widget. You can also move the widget by touching and holding it, and then dragging...
Read more >
iOS 14: How to add, remove, and customize widgets | Macworld
Once you have picked a widget and its size, tap Add Widget at the bottom of the screen. The Widget you have picked...
Read more >
Add apps, shortcuts & widgets to your Home screens
Resize a widget · Touch and hold the widget on your Home screen. · Lift your finger. If the widget can be resized,...
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