Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-21 Thread Chris Seberino


On Jul 17, 11:16 am, Justin Myers  wrote:

> or just put that one line (with a semicolon at the end, since it's
> missing one) in a 

Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-17 Thread Justin Myers
When is that code running? If it's in the head element and not
checking whether the document's finished yet, it might be executing
before the anchor you're targeting is ready. Consider either using
this, for something using jQuery:

$(document).ready(function() {
window.location = window.location + '#whatever';
});

or just put that one line (with a semicolon at the end, since it's
missing one) in a 

Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-16 Thread Daniel Roseman
On Jul 16, 2:56 pm, Chris Seberino  wrote:
> On Jul 15, 3:57 am, Oleg Lomaka  wrote:> First without 
> javascript. You cat check URL of HttpRequest and if it is without
>
> #anchor element, then send redirect to the same URL with #anchor.
>
> Yes redirection is a great non-Javascript way to do this.
>
> Is there ANY way to preserve the old form data through the
> redirection?
>
> (Imagine an invalid form that gets kicked back to the user.If I do
> a redirection must I lose the prepopulated data?)
>
> cs

Redirection will *not* work. As I said above, there is no way to
determine from the server whether or not a URL has the anchor already,
because that is never sent to the server. So if you always redirect
when you receive a URL without the anchor, you will redirect
continually.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-16 Thread Chris Seberino
On Jul 15, 3:57 am, Oleg Lomaka  wrote:
> First without javascript. You cat check URL of HttpRequest and if it is 
> without
#anchor element, then send redirect to the same URL with #anchor.

Yes redirection is a great non-Javascript way to do this.

Is there ANY way to preserve the old form data through the
redirection?

(Imagine an invalid form that gets kicked back to the user.If I do
a redirection must I lose the prepopulated data?)

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-16 Thread Chris Seberino
On Jul 15, 3:44 am, Daniel Roseman  wrote:
>      window.location = window.location + '#whatever'

I added that code to script element in head and it didn't work.

I have a TinyMCE javascript editor that gets run too.  I don't know if
that is conflicting or if there is something else I need to do to make
it work?

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-15 Thread Oleg Lomaka
Opps, Daniel is right, #anchor element isn't contains in URL, so the only way 
is javascript.


On Jul 15, 2010, at 11:57 AM, Oleg Lomaka wrote:

> I see two ways to implement this. 
> 
> First without javascript. You cat check URL of HttpRequest and if it is 
> without #anchor element, then send redirect to the same URL with #anchor.
> 
> Second using javascript. For example in jquery you can include something like 
> this in your head tag:
> 
> 
> 
> ...
> src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"; >
>
>  $(document).ready(function() {
>var offset = $('#anchor').offset().top;
>$('html, body').animate({scrollTop: offset});
>  });
>
> ...
> 
> 
> ...
> 
> ...
> 
> 
> 
> 
> 
> 
> On Jul 15, 2010, at 7:56 AM, Chris Seberino wrote:
> 
>> 
>> How can a view tweak the response object so that client sees a
>> specific anchor  instead of the top of the page?
>> 
>> Chris
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-15 Thread Oleg Lomaka
I see two ways to implement this. 

First without javascript. You cat check URL of HttpRequest and if it is without 
#anchor element, then send redirect to the same URL with #anchor.

Second using javascript. For example in jquery you can include something like 
this in your head tag:



...
http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"; >

  $(document).ready(function() {
var offset = $('#anchor').offset().top;
$('html, body').animate({scrollTop: offset});
  });

...


...

...






On Jul 15, 2010, at 7:56 AM, Chris Seberino wrote:

> 
> How can a view tweak the response object so that client sees a
> specific anchor  instead of the top of the page?
> 
> Chris
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-15 Thread Daniel Roseman
On Jul 15, 5:56 am, Chris Seberino  wrote:
> How can a view tweak the response object so that client sees a
> specific anchor  instead of the top of the page?
>
> Chris

The fragment - the bit of the URL after the "#" which determines which
anchor to scroll to - is never sent to the client, so Django can't
know whether the user has one or not. So, the obvious solution - send
a redirect to the same URL with the fragment attached - won't work,
because it will be an infinite redirection loop.

The only practical way to do this is via javascript. You just need a
script that runs on page load:

 window.location = window.location + '#whatever'

--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How can view tweak response object to go to a specific *anchor* on the template?

2010-07-14 Thread Chris Seberino

How can a view tweak the response object so that client sees a
specific anchor  instead of the top of the page?

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.