0

I'm using the sample found here http://stackoverflow.com/questions/27218680/how-can-i-reload-just-one-div-on-click and I think I'm missing something in my example or maybe the value is not passing as I'm using MPTT instead of a standard menu.

This is how I'm loading my menu found in my base.html -

{% recursetree nodes %}
    <a href="#" id="{{ node.id }}"> {{ node.name }}</a>
{% endrecursetree %}

Here is the javascript I've included -

<script>
$(document).on('click','.node',function(e) {
    id = $(this).attr("id");

    $.ajax({
        type: "GET",
        url: '/gui/details/' + id,
        success: function (result) {
            $('.details').html(result);
         },
     });
 });
 </script>

I'm then trying to use this id to reload the template here -

<div class="details">
    {% include 'gui/details.html' %}
</div>

Here is the view for generating the details -

def display_details(request, list_id):
    qs_details = Details.objects.filter(owner=request.user, list=list_id)

    return render(request, 'gui/details.html', {'qs_details': qs_details,})

Currently when I click anything on my list it doesn't do anything.

isherwood
  • 58,414
  • 16
  • 114
  • 157
whoisearth
  • 4,080
  • 13
  • 62
  • 130
  • maybe there is a message in the browser console, add it to your post, please. Did you think about the CRSF token with AJAX? try to add this decorator to your view : @csrf_exempt to be sure – Louis Barranqueiro Nov 17 '15 at 20:04
  • Found the problem, is was actually the url in the javascript. As soon as I matched it to my actual URL it was loading properly. – whoisearth Nov 18 '15 at 02:27

0 Answers0