Skip to content

Conversation

SylvainCorlay
Copy link
Member

  • Currently, there is the following bug in the widget persistence.

If Foobaris a custom widget that has a model defined in a requirejs module, specified in the _model_module widget attribute, then something like HBox([Foobar()]) won't survive a page reload.
However, Foobar() alone does persist when it is not a child of a container.

In short, custom widgets having custom models don't persist when they are children other widgets.

The symptom in the js console is the load_class complaining that undefined is not in the registry.

  • The reason is that that the creation of child widget views is done by the parent widget, at a time when their state, including _view_name and _view_module has not yet been set in the model.

Hence I changed the widget persistence mechanism, to first fetch the states of all the persisted models before instantiating any view.

Besides, the code is quite simpler, and it significantly reduces the line count.

  • Finally, this should probably be backported to 3.x.

@SylvainCorlay SylvainCorlay added this to the 4.0 milestone Jun 19, 2015
@SylvainCorlay
Copy link
Member Author

@jasongrout @jdfreder

@jasongrout
Copy link
Member

FYI, the first three hunks and the last hunk are just whitespace changes. Real changes are just lines 417-465.

@jasongrout
Copy link
Member

At a glance, this looks okay. @jdfreder, since you wrote the original code, can you take a look at this too? Thanks!

@jdfreder
Copy link
Contributor

Thanks @SylvainCorlay !

jdfreder added a commit that referenced this pull request Jun 19, 2015
@jdfreder jdfreder merged commit 23a215e into jupyter-widgets:master Jun 19, 2015
@SylvainCorlay SylvainCorlay deleted the custom_widget_persistence branch June 20, 2015 18:32
minrk added a commit to ipython/ipython that referenced this pull request Jun 21, 2015
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants