Jquery добавление дополнительных # к объектам DOM

0

Я получаю следующую ошибку в IE9

SCRIPT5022: ошибка синтаксиса, нераспознанное выражение: ## chart1 jquery-2.0.3.min.js, строка 4 символ 14519

Я не уверен, почему данный код показан ниже. Я явно не добавляю его в строку HTML и имею только 1, когда я ссылаюсь на него в вызове jqplot. Так почему же он снимает эту ошибку?

function createGraph() {
    var HTMLstring = '<!DOCTYPE html>\n';
    HTMLstring += '<HTML>\n';
    HTMLstring += '<HEAD>\n';
    HTMLstring += '<TITLE> Frequency Graph</TITLE>\n';
    HTMLstring += '<!--[if lt IE 9]><script src="js/excanvas.js"></script><![endif]-->\n';
    HTMLstring += '<script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>\n';
    HTMLstring += '</HEAD>\n';
    HTMLstring += '<BODY>\n';
    HTMLstring += '<div><span>Moused Over: </span><span id="infomouseover">Nothing</span></div>\n';
    HTMLstring += '<div><span>Clicked: </span><span id="infoclicked">Nothing</span></div>\n';
    HTMLstring += '<div id="chart1" style="margin-top:20px; margin-left:20px; width:300px; height:300px;"></div>\n';
    HTMLstring += '</BODY>\n';
    HTMLstring += '</HTML>';
    newwindow = window.open();
    newdocument = newwindow.document;
    newdocument.write(HTMLstring);
    $(document).ready(function () {
        freqchart = $.jqplot('#chart1', [
            [
                [2, 1],
                [4, 2],
                [6, 3],
                [3, 4]
            ],
            [
                [5, 1],
                [1, 2],
                [3, 3],
                [4, 4]
            ],
            [
                [4, 1],
                [7, 2],
                [1, 3],
                [2, 4]
            ]
        ], {
            seriesDefaults: {
                renderer: $.jqplot.BarRenderer,
                pointLabels: {
                    show: true,
                    location: 'e',
                    edgeTolerance: -15
                },
                shadowAngle: 135,
                rendererOptions: {
                    barDirection: 'horizontal'
                }
            },
            axes: {
                yaxis: {
                    renderer: $.jqplot.CategoryAxisRenderer
                }
            }
        });

        $('#chart1').bind('jqplotDataHighlight',
            function (ev, seriesIndex, pointIndex, data) {
                $('#infomouseover').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data + ', pageX: ' + ev.pageX + ', pageY: ' + ev.pageY);
            }
        );

        $('#chart1').bind('jqplotDataClick',
            function (ev, seriesIndex, pointIndex, data) {
                $('#infoclicked').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data + ', pageX: ' + ev.pageX + ', pageY: ' + ev.pageY);
            }
        );

        $('#chart1').bind('jqplotDataUnhighlight',
            function (ev) {
                $('#infomouseover').html('Nothing');
            }
        );
    });
}
Теги:

2 ответа

2

jqPlot() не требует выбора стиля CSS для поиска идентификатора. Он обрабатывает это сам, поэтому в настоящее время он ищет #chart1 с добавленным # дважды.

<script>
    //This will look for #chart1
    $.jqplot('chart1', [data], options );
</script>

jsplot Docs

"Создайте фактический график, вызвав плагин $.jqplot() с идентификатором вашей цели"

1

jqplot принимает идентификатор элемента как параметр, а не селектор id, поэтому $.jqplot('#chart1', должен быть $.jqplot('chart1', т.д.

http://www.jqplot.com/docs/files/usage-txt.html

Ещё вопросы

Сообщество Overcoder
Наверх
Меню