开发者

Code inside Event.observe executed continously

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <link rel="stylesheet" type="text/css" href="finance.css"/>
 <link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous.js"></script>
<script type="text/javascript" src="base64.js"></script>
<script type="text/javascript" src="canvas2image.js"></script>
<script type="text/javascript" src="canvastext.js"></script>
<script type="text/javascript" src="excanvas.js"></script>
<script type="text/javascript" src="flotr.js"></script>
<script type="text/javascript" src="HumbleFinance.js"></script>
<script type="text/javascript" src="prettify.js"></script>
<script type="text/javascript">
var priceData=[];
var dateData=[];
var NewdateData = [];
var NewData=[];
   var date1 ;
     var date2; 

     function callMe()
     {
     alert('dddw');
     }

function drawChart(data)
    {
         for (var i = 0; i < data.jobs.length; i++)  { 
             priceData.push([i, data.jobs[i].INCPU]);
             dateData.push(data.jobs[i].Dater);

            }

         HumbleFinance.init('finance', priceData , dateData);



         Event.observe(HumbleFinance.containers.summary, 'flotr:select', function (e) {

                var area = e.memo[0];
                xmin = Math.floor(area.x1);
                xmax = Math.ceil(area.x2);

              date1 = dateData[xmin];
             date2 = dateData[xmax];

                $('dateRange').update(dateData[xmin] + ' - ' + dateData[xmax]);开发者_开发百科




   alert(date1);
    alert(date2);

    This two alerts are being called continously .




            }
            );
    }

Event.observe(document, 'dom:loaded', function() {
    new Ajax.Request('/HumblFin/Serv',
            {
             method:'get',
             onSuccess: function(transport){

        var data = transport.responseText.evalJSON();

            drawChart(data);
               },
             onFailure: function(){ alert('Something went wrong...') }
            });

    });



    </script>
</head>

    <body>
<form id="sample">

<div id="finance">



<div id="dateRange">

</div>

</div>
 </form>
 </body>
</html>

The div dateRange is being updated only once , but the two alerts are being executed continuously Please help ( Like the div tag , i want my alerts also want once )


It sounds like the custom event 'flotr:select' is being fired continuously.

Looking at the limited code provided i suspect that updating the 'dateRange' element is firing the 'flotr:select' event.

if you have firebug or google chrome, put a break point into the code and examine the call stack.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜