Change document.title using X-PJAX-Title response header #22

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@sausman

sausman commented Sep 2, 2011

Setting document.title using <title> tags within views feels a bit hacky. I've been playing around with setting document.title using response.headers["X-PJAX-Title"] and it's a lot more flexible.

@levmatta-umanni

This comment has been minimized.

Show comment Hide comment
@levmatta-umanni

levmatta-umanni Sep 24, 2011

I do not know if this is considered polite, but
Plus +1 for this request idea (I am going to test it)

I do not know if this is considered polite, but
Plus +1 for this request idea (I am going to test it)

@josh

This comment has been minimized.

Show comment Hide comment
@josh

josh Feb 22, 2012

Member

Sorry, this repo does not accept patches to vendored pjax source code.

Member

josh commented Feb 22, 2012

Sorry, this repo does not accept patches to vendored pjax source code.

@josh josh closed this Feb 22, 2012

@levmatta-umanni

This comment has been minimized.

Show comment Hide comment
@levmatta-umanni

levmatta-umanni Feb 23, 2012

Please explain: "vendored" pjax source code, what is wrong with the patch.
(I would like to add that I have nothing to do with the patch creator, I just like the idea)

Again I apologize for anything wrong, please ignore me if you will.

Please explain: "vendored" pjax source code, what is wrong with the patch.
(I would like to add that I have nothing to do with the patch creator, I just like the idea)

Again I apologize for anything wrong, please ignore me if you will.

@sausman

This comment has been minimized.

Show comment Hide comment
@sausman

sausman Feb 23, 2012

I forgot about this before, but jquery-pjax is actually a separate project that pjax_rails uses. It wouldn't be a good idea to maintain a separate version of jquery-pjax within pjax_rails for many reasons.

For those who want this functionality you can use this snippet:

# PJAX update document.title
$('body').bind 'ajaxComplete', (event, xhr) ->
  title = xhr.getResponseHeader('x-pjax-title')
  document.title = title if title

Should I submit a pull request with this in lib/assets/javascripts/pjax/page_triggers.js.coffee?

sausman commented Feb 23, 2012

I forgot about this before, but jquery-pjax is actually a separate project that pjax_rails uses. It wouldn't be a good idea to maintain a separate version of jquery-pjax within pjax_rails for many reasons.

For those who want this functionality you can use this snippet:

# PJAX update document.title
$('body').bind 'ajaxComplete', (event, xhr) ->
  title = xhr.getResponseHeader('x-pjax-title')
  document.title = title if title

Should I submit a pull request with this in lib/assets/javascripts/pjax/page_triggers.js.coffee?

@josh

This comment has been minimized.

Show comment Hide comment
@josh

josh Feb 23, 2012

Member

fwiw, I don't really want to see another way to update titles in pjax. Theres already like 4 ways.

Member

josh commented Feb 23, 2012

fwiw, I don't really want to see another way to update titles in pjax. Theres already like 4 ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment