这是我的 HTML 代码:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string','Year');
data.addColumn('number','D1');
data.addColumn('number','D2');
data.addRows(2);
data.setValue(0,0,'1900');
data.setValue(1,0,'1910');
data.setValue(0,1,1);
data.setValue(1,1,2);
data.setValue(0,2,3);
data.setValue(1,2,1);
var options = {title: 'Tree Chart',
hAxis: {title: 'Time', titleTextStyle: {color: 'red'}},
pointSize: 5};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
function showChart(){
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
}
</script>
<form class="form-inline lift:form.ajax">
<div class="lift:DChart.render">
<button id="getChart" value="Get Chart" class="btn btn-inverse">Get Chart</button>
</div>
</form>
<div id="chart_div"></div>
该showChart()
函数显示图表chart_div
这是我的电梯代码:
object DChart {
def render = {
def process():JsCmd = Run("showChart();")
"#getChart" #> SHtml.button("Get Chart", process)
}
}
单击按钮应该执行该showChart()
功能..遗憾的是它不起作用..
请帮助我了解如何从 Lift 运行脚本功能!