2

When fire a click on a serie, I get the next error : Uncaught TypeError: Property 'firePointEvent' of object # is not a function.

In Highstock.js v1.3.1 (2013-04-15) on line 9575 :

// the series click event
fireEvent(hoverPoint.series, 'click', extend(e, {
    point: hoverPoint
}));

Until there, hoverPoint exist and have real values, but don't have yet firePointEvent method.

// the point click event
hoverPoint.firePointEvent('click', e);

On this next line, hoverPoint still exist and do have a firePointEvent method, but all its attributes are null. So it throws the error :/

What's the problem here?


Encountering an endless loop on an ajax function with no obvious loop

I have a file input declared as follows:

<input id = "front_photo" type = "file" name = "front_photo" onchange = "send_photo()" />

The function it calls is declared as follows:

function send_photo ()
{
    var fileInput = document.getElementById('front_photo');
    var file = fileInput.files[0];
    var formData = new FormData();
    formData.append('front_photo', file);
    console.log("in");

    var ajaxHandler = new XMLHttpRequest();

    ajaxHandler.onreadystatechange = function ()
    {
        if(ajaxHandler.readyState == 4)
        {
            var picture_box = document.getElementById("polaroids_holder");

            var adder = document.getElementById("add_polaroid");

            var new_pic = document.createElement("div");

            new_pic.className = "polaroid";

            new_pic.style.backgroundImage = "url('/assets/img/temp_front/"+ajaxHandler.responseText+"')";

            picture_box.insertBefore(new_pic, adder);

            send_photo();
        }
    }

    ajaxHandler.open('POST', 'upload_polaroid', true);
    ajaxHandler.send(formData);
}

Selecting a file to upload once causes it to go into an endless loops. The "in" I have there at the top is piling up in the console log, so I'm sure it's the function itself being called repeatedly and not a server side redirect. Also, the images are being created on the server. Here's the PHP for that:

function upload_polaroid ()
    {
        if(isset($_FILES['front_photo']))
        {
            $format = explode(".", $_FILES["front_photo"]["name"]);
            $format = $format[1];
            $filename = md5(mt_rand().microtime(true)).".".$format;
            $allowedTypes = array("image/tiff", "image/gif", "image/jpeg", "image/png", "image/x-bmp", "image/x-ms-bmp", ".bmp", ".dib", "image/vnd.microsoft.icon", "image/x-xbitmap", "image/x-xbm", ".xbm", ".cur");

            if(in_array($_FILES["front_photo"]["type"], $allowedTypes))
            {
                if(file_exists(getcwd()."/assets/img/temp_front/".$filename)) 
                {
                    chmod(getcwd()."/assets/img/temp_front/".$filename,0755);
                    unlink(getcwd()."/assets/img/temp_front/".$filename);
                }

                move_uploaded_file($_FILES["front_photo"]["tmp_name"], getcwd()."/assets/img/temp_front/".$filename);
                $image_path = "/assets/img/temp_front/".$filename;
                echo $image_path;
            }
            else
            {
                echo "File is not of a valid image type."; die;
            }
        }
        else
            die; //var_dump($_FILES);
    }

What could be going wrong here?

4

1 回答 1

2

我可以重现这个问题。你可以在 这个 fiddle中看到它。

  1. 单击图表背景(它会删除线条)
  2. 然后单击该系列(该行返回并触发错误)

我找到了一个解决方法,你必须设置一点超时,这样点击事件和更新过程就不会在同一个调用中发生。

我猜这update()会使hoverPoint对象被更改,导致firePointEvent属性null处于进程的末尾。

这里的解决方法:(在 JSFiddle 这里

plotOptions: {
        series: {
            events: {
                click: function(event) {
                    var that = this;
                    setTimeout( function(){
                        that.update({
                            lineWidth: 1,
                        });
                    }, 20);

                }
            }
        }
},
于 2013-05-20T14:21:40.030 回答