Getting stuck, partial success

19 views
Skip to first unread message

Joseph Leon

unread,
Dec 3, 2014, 9:13:47 PM12/3/14
to django-s...@googlegroups.com
Here is a paste of my models, lookups, forms and js.


I have a region select which when a region is selected it should auto populate the place select, when a place is selected it should populate the building.

With my current code it creates a drop down in the place field with all place names followed by the region name. When the region field is selected nothing happens at all, it still shows all the places when it should filter them down.

I feel like I'm close but I'm missing something.

Mark Lavin

unread,
Dec 3, 2014, 9:19:38 PM12/3/14
to django-s...@googlegroups.com

It looks like the JS code passes the value as a parameter named 'state' but the lookup code expects it to be called 'region'.

-Mark

--
You received this message because you are subscribed to the Google Groups "django-selectable" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-selecta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joseph Leon

unread,
Dec 4, 2014, 6:24:42 AM12/4/14
to django-s...@googlegroups.com
It wasn't that, I ended up solving it. The example js code from the docs doesn't have the code wrapped in a .change() function thus never gets run when the user selects a region. 

Here's the code that fixed it:

$('#id_region').on('change', function() {
    function newParameters(query) {
      query.region = $('#id_region').val();
    }

    $('#id_place_0').djselectable('option', 'prepareQuery', newParameters);
  });
Reply all
Reply to author
Forward
0 new messages