按钮 - 更新图形 - 抛出SyntaxError

时间:2017-04-06 14:59:11

标签: javascript jquery button 3d

PDB结构加载正常,但是当我使用按钮更新图像时,它将无法正常工作。它制作了一个" Uncaught SyntaxError:Unexpected token}"

真的不明白为什么会这样,按钮应该从3Dmol.js调用一个方法并重新绘制。 我简化了示例,因为有多个按钮可以更改样式并添加删除标签。

此处的原始示例:https://github.com/3dmol/3Dmol.js/blob/master/tests/example.html

   <!DOCTYPE html>
    <html>
    <head>
        <title>3Dmol Example - Changing render options</title>

        <link href="Library/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link type="text/css" rel="stylesheet" href="style.css">

        <!-- Load Online API; defer scripts so they execute after the html has been parsed  -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="Library/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
        <script defer src="http://3Dmol.csb.pitt.edu/build/3Dmol-min.js" ></script>
    </head>

    <body>
        <!-- Container for whole page  -->
        <div class='container'>
            <!-- Row for PDB and Plot -->
            <div class='row'>
                <div class="col-md-12" >
                    <div id='viewer3' class='viewer_3Dmoljs' style="width: 600px; height: 600px; float:left;"
                    data-pdb='3SN6' data-backgroundcolor='0xffffff' data-style='{"cartoon":{}}'>
                </div>
            </div>
        </div>
        <!-- Row for buttons  -->
        <div class="row">
            <div class="col-md-8">
                <div id="gldiv" style="width: 600px; height: 600px; margin: 0; padding: 0; border: 0;"></div>
          <div class="col-md-4">
          <hr style="margin: 0;">

                <input type="button" value="Stick"
                onclick="$3Dmol.viewers["viewer3"].setStyle({},{stick:{}}); $3Dmol.viewers["viewer3"].render();"></input>

                <input type="button" value="Label alpha C's"
                onclick=addLabels($3Dmol.viewers["viewer3"]); $3Dmol.viewers["viewer3"].render();"></input>

                <input type="button" value="Remove labels"
                onclick="$3Dmol.viewers["viewer3"].removeAllLabels(); $3Dmol.viewers["viewer3"].render();"></input>
                    </div>
          </div>
            </div>
        </div>
    </div>
    </body>
    </html>

0 个答案:

没有答案