Hi, David, it seems that periodicalupdater send request first,
breaking down the preview code
setting new Ajax.Request. And the object is no longer refering to the
gotopreview function.
Because the firebug console returns the link that the
periodicalupdater request sever to update something,
just after that I move over any of the four elements (toplink), it
doesn't work.
Event.observe(window,'load',function(){
var elms = document.getElementsByClassName("toplink");
Event.observe(elms[0],'mouseover',function(ev){gotopreview(ev,
0);});
Event.observe(elms[1],'mouseover',function(ev){gotopreview(ev,
1);});
Event.observe(elms[2],'mouseover',function(ev){gotopreview(ev,
2);});
Event.observe(elms[3],'mouseover',function(ev){gotopreview(ev,
3);});
});
So, my question is, how can I do the following things.
1. PreriodicalUpdater sending data to Sever and Sever return
something;
2. Then, Event.observe(elms[x]) can keep doing its part of job without
being broken by preriodicalUpdater.
Is it my logic correct? or Wrong somewhere? Thanks for your help.
On Mar 6, 8:24 pm, david <[email protected]> wrote:
> Hi SamuelXiao,
>
> about the bind or bindAsEventListener method, it does not help in your
> case.
> Those two functions are used to force the value of 'this', but you are
> not inside a class, and do not use 'this' inside the gotopreview
> function.
>
> I made testiung with given code, but there is some elements missing,
> is it possible to have a live exemple to see the problem
>
> --
> david
>
> On 2 mar, 14:11, SamuelXiao <[email protected]> wrote:
>
> > My code is to preview webpages when user move mouse over <a></a>. At
> > the same time, my code has other parts using Prototype
> > periodicalupdater.
> > The following code can work well independently:
>
> > // javascript preview program start
> > var ci;
> > var xPos,yPos;
> > Event.observe(window,'load',function(){
> > var elms = document.getElementsByClassName("toplink");
> > Event.observe(elms[0],'mouseover',function(ev){gotopreview(ev,
> > 0);});
> > Event.observe(elms[1],'mouseover',function(ev){gotopreview(ev,1);});
> > Event.observe(elms[2],'mouseover',function(ev){gotopreview(ev,2);});
> > Event.observe(elms[3],'mouseover',function(ev){gotopreview(ev,3);});
>
> > });
>
> > function gotopreview(event,ci){
> > alert(ci);
> > xPos = Event.pointerX(event);
> > yPos = Event.pointerY(event);
> > var getpostid=document.getElementsByName("targetpid");
> > var getsid = document.getElementsByName("stdid");
> > var url = "getOnePost.php";
> > var pars = "stdid="+getsid[ci].value + "&targetpid=" + getpostid
> > [ci].value;
>
> > var myajax = new Ajax.Request(url,{
> > method:'get',
> > parameters: pars,
> > asynchronous: true,
> > onSuccess: function(transport){
> > $('previewWin').update(transport.responseText);
> > $('previewWin').style.top = parseInt(yPos) + 2 +
> > "px";
> > $('previewWin').style.left = parseInt(xPos) + 2 +
> > "px";
> > $('previewWin').style.visibility = "visible";
> > $('previewWin').onmouseout =function(){ $
> > ('previewWin').style.visibility = "hidden";}
>
> > }
> > });}
>
> > // javascript preview program end
> > // The above code can work well independently.
>
> > And my html page is link:
> > <html>
> > <head>
> > </head>
> > <body>
> > <a class="toplink" value="XXX">XXX</a>
> > <a class="toplink" value="XXX">XXX</a>
> > <a class="toplink" value="XXX">XXX</a>
> > <a class="toplink" value="XXX">XXX</a>
> > <div id="previewWin"></div>
> > </body>
> > </html>
>
> > But when it comes to work with the periodical updater, it seems that
> > periodicalupdater send request first, breaking down the preview code
> > setting new Ajax.Request. And the object is no longer refering to the
> > gotopreview function.
>
> > The following is my periodical code,
>
> > obj = new Object();
> > obj.f1 = eventHandler;
> > window.onload = obj.f1;
> > window.onunload = function(){};
>
> > function eventHandler(){
> > postUpdater();
>
> > }
>
> > function postUpdater() {
> > var myAjax = new Ajax.PeriodicalUpdater(
> > "recentPost",
> > "recentPost.php",
> > {
> > method: 'get',
> > frequency: 50
> > });
>
> > }
>
> > I use firebug to check the program and found that before I move mouse
> > over the "toplink" anchor, the postUpdater() function will send
> > request to the Sever thus, my preview code is no longer work. I know
> > that there is bind and bindAsListener function to bind the gotopreview
> > function. I tried but it's not work also, could some one help me or
> > tell me how to modify the code to make it work? Is there any way stop
> > the periodicalUpdater when it is loaded? Or if I must to use bind or
> > bindAsListener, how to write it correctly in the above code? Any help
> > would be appreciated!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---