Try our conversational search powered by Generative AI!

Force full refresh when content of specific type is added to a content area?

Vote:
 

It's possible to force a full page refresh when some specified properties have been modified. However, imagine that we have a scenario where we have a block whose renderer relies on some Javascript being executed on DOM ready. The renderer adds full refresh for properties that affect the JS so when editing the block the editor gets a realistic preview.

If such a block is added to a content area the javascript won't, naturally, be executed causing the editor to see that the block has been added but she/he won't see it rendered correctly. This could of course be handled by adding full refresh for content area properties but that seems like a shame as it would mean that any change to a content area would cause a page refresh and thereby slowing down the experience for the editor.

So, one question and one feature request:

1. Is there some simple solution to this that I'm missing? Ie forcing a full page refresh depedning on _what_ is done to a property, specifically a content area?

2. Perhaps the edit UI could inspect added content and see if the renderer adds full refreshes for any properties. If so, trigger a full request when such a content/render is added?

#65135
Jan 22, 2013 9:58
Vote:
 

Editing UI should reload the entire page if property rendering result contains "<script" string.

As a workaround you could render empty script tag in block template in edit mode. Something like this:

if (PageEditing.PageIsInEditMode)
{
    // Hack: output "<script></script>" to reload
}

 

As far as I know this is the the only one way for now. Is it what you need?

#65141
Edited, Jan 22, 2013 12:46
Vote:
 

I second your questions Joel. They somewhat relates to my questions here http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=65075&epslanguage=en

#65144
Jan 22, 2013 13:03
Vote:
 

Thanks Dmytro, I'm using the client resource handling to put the scripts in header/footer but the edit-mode-only hack I can certainly work with.

#65148
Jan 22, 2013 13:27
Vote:
 

Damn, it didn't actually solve my problem. Instead it produced an odd result.

If I don't have a script tag in the view for the block the block gets added but the JS isn't executed. If I do have an empty script tag the page gets reloaded but the block isn't rendered in the content area. The block has been added though, as I can see it in the list if I click on the content area. It's also rendered correctly if I hit refresh in the browser.

Thoughts?

#65150
Jan 22, 2013 13:42
Vote:
 

OK, so, here's a bug for you Dmytro. Sorry about this ;)

Adding a script tag to a block DOES force a full refresh of the page.

If there is only a single version of the page it always works.

If there is published version of the page (or maybe just an older one, I don't know) it DOES force a full refresh of the page but the block is NOT rendered in the content area. My theory is that an older version of the page is loaded.

IF the script tag does something that takes a fair amount of time, for instance contains an alert which the user is slow to dismiss, the correct version is loaded and the content area is rendered with the block inside.

IF the script tag contains a setTimeout, like the one below, it loads with or without the block inside depending on the timeout value. For instance on my machine with a 100ms it never loads the updated content area while with 1s it almost always load the updated content area.

@if(PageEditing.PageIsInEditMode)
{
    <script> setTimeout(function() {
        var supernastyhacksuperduper = 42;
     }, 100);
    </script>   
}

How bout that ;)   

 

 

#65153
Jan 22, 2013 14:22
Vote:
 

Line 5.

What is the officially recommended timeout value by EPiServer? 

:P

#65155
Edited, Jan 22, 2013 14:27
Vote:
 

If you are working on published version, the first change you made would create a new version. Meanwhile, your change has triggered a full page reload. Both of these actions force the edit mode to do some re-initializations. I guess that we have some mis-synced promises over there. However, I have no clue why a timeout would help. I will investigate a little bit more and let you know if a bug is filed.

#65220
Jan 23, 2013 12:21
Vote:
 

Nice steps to reproduce, Joel :)

#65224
Jan 23, 2013 13:09
Vote:
 

There's a reason I opted to write here rather than to post a bug. Sorry ;-)

#65225
Jan 23, 2013 13:12
Vote:
 

Dmytro and Duong,

I just ran into something really annoying that I believe is related to this. I have a scheduled job that imports pages from another site. It either creates new pages or updates existing ones. The imported pages has a ContentArea property. For existing ones I clear this property and populate it with new values. This doesn't work. I can add new values to the content area but I can't clear it's values. I've tried everything I can think of including clearing it in different ways such as .Prop = new ContentArea(), .Prop = null, .Property["Prop"].Clear() and about 10 other ways. I've also experimented with different SaveActions but nothing works.

What does work though is first clearing the property and then waiting for a little while before saving the page.

Again I don't have good steps to reproduce but I think/hope this makes sense to you guys. This bug has just cost med three hours and nearly depleated my WTF quota for the week :)

I'm running Patch 1.

#65983
Edited, Feb 17, 2013 22:16
Vote:
 

Was there any traction made on this issue?  I am experiencing something similar as well.  

We are using a slightly modified version of the Itera.Multiproperty library to create, in this instance, a list of key-value pairs ("ConfigProperty") on a particular page type ("KeyValuesPage") which uses the legacy editor.  This is rendered via a Repeater.  I surrounded the Repeater with a div ("divWrapper"), and on page load I use the following snippet to add on-page edit:

 

divWrapper.ApplyEditAttributes<KeyValuesPage>(p => p.ConfigProperty);

this.EditHints.AddFullRefreshFor(x => x.ConfigProperty);

// Code to databind repeater...

 

The first time I edit the page and make an update, I hit save in the legacy editor modal and the page refreshes.  The updated data, however, is not reflected in the repeater.  Re-opening the legacy editor DOES show the updated values. If I publish the page my updates are reflected.

Another odd quirk:  If I don't publish the page after the first refresh "fails", and I try updating the property a second time, it works as expected.  The problem is just the first full refresh.

#72179
Edited, Jun 10, 2013 16:04
Vote:
 

I would also like to have an answer...


Full Refresh seems really buggy. Works sometimes. Im rendering a date to the preview page and the date gets updated, but sometimes no new data is loaded. Sometimes the data is empty for the property with full refresh (most often a content area).

#72180
Jun 10, 2013 16:09
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.