事件内部代码。观察持续执行

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>
Div DateRange仅更新一次,但两个警报正在连续执行 请帮助(就像div标签一样,我希望我的警报也想要一次)

推荐答案

听起来像是在连续触发自定义事件'flotr:select'

查看提供的有限代码,我怀疑更新'dateRange'元素会激发'flotr:select'事件。

如果您有FireBug或Google Chrome,请在代码中放置断点并检查调用堆栈。

这篇关于事件内部代码。观察持续执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:事件内部代码。观察持续执行

基础教程推荐