hi there
i want to update more than one elements in the HTML DOM using Ajax.
Please look at the following code:
function forward() {
var url = ''ajax/paginate.php'';
var pars = ''direction=forward'';
var target = ''content'';
var ajax = new Ajax.Updater(target, url, {method: ''get'',
parameters:
pars});
}
Not only ''content'' must be updated (this works fine), but also
another
element (''page-number''). This element must be updated with the
new
page number witch is also generated by ''ajax/paginate.php''.
''page-
number'' is somewhere else in the DOM.
Who can help me?
<< i''m a newbe on prototype >>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
one way you could do this is to get the new page number with an
AJAX.Request before you call theupdater onComplete:
$("page_num_div_id").innerHTML = ''whatever''
but honestly, why aren''t you just putting the page number in the same
div as the ajax content? otherwise, if you are grabbing DB content
this will mean running the query twice. Once to get the page number,
once to get the data.
another option, if the number of pages is set i.e. they can''t change
from 5 to 10 rows per page then you could use a js function to just
increment or decrement the value in the page number div.
On Oct 31, 2007 3:57 PM, richard
<richard.chantal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> hi there
>
> i want to update more than one elements in the HTML DOM using Ajax.
> Please look at the following code:
>
> function forward() {
> var url = ''ajax/paginate.php'';
> var pars = ''direction=forward'';
> var target = ''content'';
> var ajax = new Ajax.Updater(target, url, {method:
''get'', parameters:
> pars});
> }
>
> Not only ''content'' must be updated (this works fine), but
also another
> element (''page-number''). This element must be updated
with the new
> page number witch is also generated by
''ajax/paginate.php''. ''page-
> number'' is somewhere else in the DOM.
>
> Who can help me?
>
> << i''m a newbe on prototype >>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
This can''t be done with Ajax.Updater as far as I know, so you would
have to use Ajax.Request and figure out a way to seperate your
content... You could either send the page number in a JSON header
alongside your content or you could send everything as JSON.
// this is how your JSON would look then...
var json = [{ page: 3, content: ''<div>bla bla
bla</div>'' }]
On Oct 31, 9:14 pm, "Brian Williams"
<brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> one way you could do this is to get the new page number with an
> AJAX.Request before you call theupdater onComplete:
> $("page_num_div_id").innerHTML = ''whatever''
>
> but honestly, why aren''t you just putting the page number in the
same
> div as the ajax content? otherwise, if you are grabbing DB content
> this will mean running the query twice. Once to get the page number,
> once to get the data.
>
> another option, if the number of pages is set i.e. they can''t
change
> from 5 to 10 rows per page then you could use a js function to just
> increment or decrement the value in the page number div.
>
> On Oct 31, 2007 3:57 PM, richard
<richard.chan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > hi there
>
> > i want to update more than one elements in the HTML DOM using Ajax.
> > Please look at the following code:
>
> > function forward() {
> > var url = ''ajax/paginate.php'';
> > var pars = ''direction=forward'';
> > var target = ''content'';
> > var ajax = new Ajax.Updater(target, url, {method:
''get'', parameters:
> > pars});
> > }
>
> > Not only ''content'' must be updated (this works
fine), but also another
> > element (''page-number''). This element must be
updated with the new
> > page number witch is also generated by
''ajax/paginate.php''. ''page-
> > number'' is somewhere else in the DOM.
>
> > Who can help me?
>
> > << i''m a newbe on prototype >>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Thats must be the solution. More and more I got into JSON and I understand it better. Your solution fits exactly in the ideas of JSON with AJAX. As far I know now, JSON can be read by the client''s javascript. 1. AJAX request to the server 2. server builds an JSON string en response it to the client 3. client understands the JSON and handles it like ''normal'' javascript objects (ONLY properties, NO methods, right?) Am I right about this? Thanks, Richard On 1 nov, 12:41, Wizz <woutaw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This can''t be done with Ajax.Updater as far as I know, so you would > have to use Ajax.Request and figure out a way to seperate your > content... You could either send the page number in a JSON header > alongside your content or you could send everything as JSON. > > // this is how your JSON would look then... > var json = [{ page: 3, content: ''<div>bla bla bla</div>'' }] > > On Oct 31, 9:14 pm, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > one way you could do this is to get the new page number with an > > AJAX.Request before you call theupdater onComplete: > > $("page_num_div_id").innerHTML = ''whatever'' > > > but honestly, why aren''t you just putting the page number in the same > > div as the ajax content? otherwise, if you are grabbing DB content > > this will mean running the query twice. Once to get the page number, > > once to get the data. > > > another option, if the number of pages is set i.e. they can''t change > > from 5 to 10 rows per page then you could use a js function to just > > increment or decrement the value in the page number div. > > > On Oct 31, 2007 3:57 PM, richard <richard.chan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hi there > > > > i want to update more than one elements in the HTML DOM using Ajax. > > > Please look at the following code: > > > > function forward() { > > > var url = ''ajax/paginate.php''; > > > var pars = ''direction=forward''; > > > var target = ''content''; > > > var ajax = new Ajax.Updater(target, url, {method: ''get'', parameters: > > > pars}); > > > } > > > > Not only ''content'' must be updated (this works fine), but also another > > > element (''page-number''). This element must be updated with the new > > > page number witch is also generated by ''ajax/paginate.php''. ''page- > > > number'' is somewhere else in the DOM. > > > > Who can help me? > > > > << i''m a newbe on prototype >>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---