Comments (12)
Thanks for your extensive description of the problem. I could reproduce it here: http://jsfiddle.net/5uXFS/10/
I asked on #jquery:
14:21 < jpic> hi all, is it possible to bind a callback for when an attribute (id) changes on an element ?
14:21 < quicksilver> no.
14:22 < quicksilver> or at least, not effectively and portably.
14:22 < quicksilver> DOM change events exist but browsers do not support them well.
According to a similar question, we should use the mutation watcher plugin to catch id attribute changes.
We could then do appropriate copies in widget and autocomplete registry - which is still some work.
from django-autocomplete-light.
I just got some tremendous answers from #jquery concerning our problem. Using .data instead of our registry array, should support cloning (and thus, inlines): http://jsfiddle.net/5uXFS/35/
Also, it reduces our codebase for free. So I'm working on that right away B)
from django-autocomplete-light.
The solution in the above commit works for the example: http://localhost:8000/admin/dependant_autocomplete/dummy/
Could you try it and confirm that it works for you too ?
Thanks !
from django-autocomplete-light.
Released in 1.0.13, please re-open the issue if any problem occur.
from django-autocomplete-light.
Please reopen this one.
Here's the story:
from django-autocomplete-light.
Ok, it's not perfect ... because it would add a lot of overhead to monitor DOM changes: there is an API but it is barely supported by some browser at this point. The other solution would be to override django's function that creates the inline, which sounds like a very bad idea...
But still, if you're just trying to get dependency between autocompletes in inlines to work, doesn't this example do it ? http://localhost:8000/admin/dependant_autocomplete/dummy/add/
Note that, I had to change the script: http://django-autocomplete-light.readthedocs.org/en/latest/dependant.html#javascript
Tell me what you think of the example, does it work as you expect ?
from django-autocomplete-light.
Also, in your example, this works:
$('#trip_city_set-3 .field-city .autocomplete-light-widget').yourlabsWidget()
from django-autocomplete-light.
I'm going to implement DOMAttrModified event support anyway, hopefully browsers will catch up.
from django-autocomplete-light.
$('#id_trip_city_set-2-city-wrapper').yourlabsWidget() should also work
from django-autocomplete-light.
I did find a really blocking issue thought, seen on remote autocompletes in inlines
updateWidgets() initializes newly created widgets although it shouldn't, and thus custom initialization as described here doesn't work.
A fix was implemented in branch solid_init but I have to make sure that everything still works and figure whether it's backward compatible or not (it might actually be) before I can merge it. Meanwhile, feel free to experiment with it maybe it illustrates your issue.
Until then, documentation for this branch is available
from django-autocomplete-light.
I'm pretty sure this will eliminate whatever problem you have ... please let me know (note that you have to change your custom javascript to use bind('initialize' etc ... see documentation and comment in source code)
from django-autocomplete-light.
Fix released in 1.0.14. Read the CHANGELOG to figure how to benefit from the new initialization pattern. Please reopen if your issue subsists.
from django-autocomplete-light.
Related Issues (20)
- Properly load js and set zindex with DAL in a BSModal HOT 1
- 'list' object has no attribute 'queryset' HOT 7
- Missing sourcemap for `nucleus.css` HOT 3
- Enable duplicate selection HOT 3
- Collectstatic error with whitenoise on 3.9.5 (same as #1281) HOT 11
- Django Widget protocol not implemented properly in WidgetMixin HOT 2
- WidgetMixin __init__ breaks when attrs is None HOT 1
- DAL compatibility with other widgets
- Dal 3.10 not working with django 4.2 HOT 1
- Filtering results based on the value of other fields in the form - issue when i reselect the first field then second field does none change to none
- DAL generates multiple selectboxes for declarative field HOT 1
- DAL 3.10.4rc breaks autocomplete views HOT 5
- autocomplete.ModelSelect2 () not working in bootstrap5 modal HOT 1
- Django Autocomplete light Forward fields outside Admin
- Forward id for a models.ForeignKey("self") HOT 2
- Tutorial gives core not found error
- Wrong selection when clicking on bottom area of item
- Non-rc release forthcoming? HOT 3
- Cloning an autocomplete form dynamically HOT 8
- The selected filter does not filter the model in the admin panel
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-autocomplete-light.