2013-06-05 134 views
0
下一页

我在我的app.For选择标记使用的地图API,按钮命名为“Add marker”和“Refresh map"进行刷新map.I现在所面临的在这里。页面重定向到

保存数据,在后保存按钮将重定向到下一页。在我的情况下,两个“添加标记”,"Refresh map"都在做保存按钮作业,如果我按"Add marker"而不是显示标记,页面将重定向到下一页。使用</form> 。在这里看到我的模板,

<form method="POST" action="/member/where/" > 
{% csrf_token %} 
<td colspan="2" class="incident-type" style="padding-left:25px"> 
    {% for location in locationList%} 
    {% if location.parent_location_id == None %} 
    <h1>{{location.title}}</h1> 
    {% endif %} 
{% endfor %} 
<p> 
<span class="map_buttons" >{% include "buttons/refreshmap.html" %}</span> <span class="map_buttons" style="margin-left:20px;">{% include "buttons/addmarker.html" %} </span> 
</p> 
<p id=ir-nextbtn>{% include "buttons/next.html" %}</a></form></p> 

refreshmarker.html

<button type="submit" title="Refresh map" class="map_buttons button_style">Refresh map</button> 

addmarker.html

<button type="submit" title="Add marker" class="map_buttons button_style">Add marker</button> 

需要澄清这个问题。

+0

你能粘贴按钮的html吗?都是按钮提交按钮? – 2013-06-05 06:41:38

+0

@Rhea,两个HTML,更新。 –

回答

1

问题是因为这两个按钮都是submit类型,当您单击其中一个按钮时,表单将被提交。其结果是,该页面被重定向OTO形式即/成员/在/

试试这个的action: - 不断刷新,因为它是

<button type="submit" title="Refresh map" class="map_buttons button_style">Refresh map</button> 

,并添加

<button onClick=somefuntion(this)' title="Add marker" class="map_buttons button_style">Add marker</button> 

并让一些功能做好需求

<script> 
function somefuntion(button){ 
    // your code 
    document.forms[0].submit() // this will submit your form 
} 
</script>