Skip to content

Instantly share code, notes, and snippets.

@maccevedor
Created June 24, 2015 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maccevedor/899100fd9f7f9bd8a300 to your computer and use it in GitHub Desktop.
Save maccevedor/899100fd9f7f9bd8a300 to your computer and use it in GitHub Desktop.
{# src/DMW/DemoBundle/Resources/views/Notice/index.html.twig #}
{% extends 'DMWDemoBundle::layout.html.twig' %}
{% block content %}
<div>
<p>Noticias recientes</p>
<ol>
{% for index,notice in notices %}
<li><a href="{{ path('DMWDemoBundle_noticeView', {'notice_id': index}) }}">{{notice.title}}</a></li>
{% endfor %}
</ol>
<div id="notice_viewer">
{# en esta capa serán cargadas las noticias por ajax #}
</div>
</div>
{% endblock content %}
{# extendemos el bloque javascript #}
{% block javascripts %}
{{parent()}} {# incluimos las declaraciones de script del layout, como jQuery #}
<script type="text/javascript">
$(document).ready(function(){
$('a.notice_link').click(function(event){
event.preventDefault(); //cancela el comportamiento por defecto
$('#notice_viewer').load($(this).attr('href')); //carga por ajax a la capa "notice_viewer"
});
});
</script>
{% endblock javascripts %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment