[英]I can not go back to previous page using .load() jquery
I can not go back to the page cal.html after loading tareas.html 我不能回去的页面加载cal.html后tareas.html
index.html
cal.html
tareas.html
---index.html----- --- index.html的-----
<div id="contenedor">
</div>
//content calendar here ---calendar.html--- //这里的内容日历--- calendar.html ---
<div>
<div class="tabs colortopbar" id="tabtarea">
<div class="tab-item colortextbar bartabcolor">
Calendario
</div>
<div class="tab-item colortextbar" id="agregar">
Agregar
</div>
</div>
</div>
//content list here ---tareas.html--- //这里的内容列表--- tareas.html ---
<div>
<div class="tabs colortopbar" id="tabtarea">
<div class="tab-item colortextbar" id="calendar">
Calendario
</div>
<div class="tab-item colortextbar bartabcolor">
Agregar
</div>
</div>
</div>
this is to load tareas.html, work 这是加载tareas.html,工作
$('#agregar').click(function(){
$('#contenedor').load('tareas.html');
});
this is to load cal.html, this don't work, how to fix this? 这是要加载cal.html,这不起作用,如何解决?
$('#calendar').click(function(){
$('#contenedor').load('cal.html');
});
I don't see #agregar or #calendar on your index page where I would expect this workflow to begin. 我在您希望此工作流程开始的索引页面上没有看到#agregar或#calendar。 Assuming those elements are there on your index page, you will find that the new #agregar and #calendar elements you are loading in your partials do not have events bound to them.
假设这些元素在索引页面上,您将发现在局部中加载的新的#agregar和#calendar元素没有绑定到它们的事件。 The events are bound once on page load.
这些事件在页面加载时绑定一次。
There are lots of ways to handle this depending on your framework, but ultimately you will want to employ event delegation . 有很多方法可以解决此问题,具体取决于您的框架,但是最终您将需要使用事件委托 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.