-
Notifications
You must be signed in to change notification settings - Fork 1k
Knockout web part with properties fails when running in SharePoint #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanx for reporting. We will look into this. |
This is fixed in the next drop. For now, you can replace the _description variable in the generated code with _koDescription, and that will fix the issue. |
@patmill - this is not the same issue as already logged, it's when using any properties in the knockout template, then running it in the SharePoint workbench. |
Great. From: Pat Miller [mailto:[email protected]] This is fixed in the next drop. For now, you can replace the _description variable in the generated code with _koDescription, and that will fix the issue. — |
@davros85 - Got it, thanks. I read Knockout and Description, and jumped to the wrong answer. |
OK, picking up on this. The first issue is that the this.properties does not exist in the constructor, as we have not yet deserialized them. We added an extra step here to handle issues around persisted data schema drift (version 2 of the webpart expects data in a different format, so we need to give the developer a change to fix up the data that they were handed). The right place to do most of this is in onInit. However, for some reason the compontentElement doesn't have the template HTML in it when it is being set. I'm not exactly a knockout expert, so having a bit of difficulty sorting out what the issue here is. At any rate, to move to the next step, pull everything out of the constructor after
|
OK, more information. Here's the workaround, as well as what the underlying bug is. The underlying issue for why onInit() isn't working is that there is logic to handle onInit() taking too long that involves modifying the DOM to show a spinner. The spinner is supposed to be an overlay that is cleared, but currently is deletes the contents of the DOM, which wipes out the knockout stuff. So for now, do this: 0 - Update your constructor to look like this
1 - Create a new function
2 - Update your Render method to look like this
|
Brill - thanks - tried it and it works, fixes the undefined property issue as well as the web part disappearing. |
This is fixed now. |
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues |
Thank you for reporting an issue or suggesting an enhancement. We appreciate your feedback - to help the team to understand your needs, please complete the below template to ensure we have the necessary details to assist you.
Category
Expected or Desired Behavior
That after building a new project based on the knockout template you should be able to run it in the Workbench within SharePoint.
Observed Behavior
When running in the local workbench, web part renders and custom properties are fine. When running in the Workbench in SharePoint, errors are logged below the web part. With a new, untouched project this is "Cannot read property 'description' of undefined".
Steps to Reproduce
Yo a new project using knockout, (fix the _description bug), and run it in the Workbench in a SharePoint dev tenant.
The text was updated successfully, but these errors were encountered: