Created by @fix in Q&As
@fix
@fix

Hi,

I have a problem with <title></title> change after ajax request.

When I set <title n:snippet="title">, add 'title' to default snippets array (setDefaultSnippets), open page in browser and then load another page by ajax, it replaces <title> text by the new one but after a few milliseconds, it replaces <title> back to the previous page's title text.

Is is a bug or am I doing something wrong?

Thank you.

fix

@tomasstofik
@tomasstofik

Hi, same here. Spen 2 hours with that. I tried snippetArrea but same behavior with/whout included templates. Everything in body is redrawn except head section. Any ideas?

@fix
@fix

Hi, solved. Solution is posted here: https://forum.nette.org/cs/25506-nittro-novinka-pro-vas-frontend-puvodne-nettejs?p=2

<!-- NITTRO title rerendering fix -->
<script type="text/javascript">
    _context.invoke(function(HistoryAgent, Strings) {
        HistoryAgent.prototype._handleResponse = function (data, evt) {
            var payload = evt.data.response.getPayload();

            if ('snippets' in payload && 'snippet--title' in payload.snippets) {
                data.title = Strings.escapeHtml(payload.snippets['snippet--title']);
            } else if (payload.title) {
                data.title = payload.title;
            }
        };
    }, {
        HistoryAgent: 'Nittro.Page.HistoryAgent',
        Strings: 'Utils.Strings'
    });
</script>

Sign in to post a reply