Giter Site home page Giter Site logo

Comments (12)

jpic avatar jpic commented on May 18, 2024

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.

jpic avatar jpic commented on May 18, 2024

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.

jpic avatar jpic commented on May 18, 2024

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.

jpic avatar jpic commented on May 18, 2024

Released in 1.0.13, please re-open the issue if any problem occur.

from django-autocomplete-light.

mpasternak avatar mpasternak commented on May 18, 2024

Please reopen this one.

Here's the story:

This is okay

Let's add some more fields

Whoa, let's check the HTML then! It looks okay... thanks for fixing it, jpic... why doesn't it work then?!

We've got it!

from django-autocomplete-light.

jpic avatar jpic commented on May 18, 2024

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.

jpic avatar jpic commented on May 18, 2024

Also, in your example, this works:

$('#trip_city_set-3 .field-city .autocomplete-light-widget').yourlabsWidget()

from django-autocomplete-light.

jpic avatar jpic commented on May 18, 2024

I'm going to implement DOMAttrModified event support anyway, hopefully browsers will catch up.

from django-autocomplete-light.

jpic avatar jpic commented on May 18, 2024

$('#id_trip_city_set-2-city-wrapper').yourlabsWidget() should also work

from django-autocomplete-light.

jpic avatar jpic commented on May 18, 2024

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.

jpic avatar jpic commented on May 18, 2024

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.

jpic avatar jpic commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.