GithubHelp home page GithubHelp logo

Comments (17)

vitorfragoso avatar vitorfragoso commented on July 17, 2024 1

Any news? Thanks!

from django-smart-selects.

codekoala avatar codekoala commented on July 17, 2024

I'm going to be trying to come up with a solution for this in the near future..... hopefully tomorrow!

from django-smart-selects.

antoniopicone avatar antoniopicone commented on July 17, 2024

Any news on this bug ? Thanks ;)

from django-smart-selects.

codekoala avatar codekoala commented on July 17, 2024

Nope, sorry. Turned out that my project didn't need the smart selects after all. They were too simplistic for what I needed, so I am now generating dynamic forms with JavaScript.

from django-smart-selects.

dsm2005 avatar dsm2005 commented on July 17, 2024

I have this problem, too.

from django-smart-selects.

sebasgoldberg avatar sebasgoldberg commented on July 17, 2024

Me too.

Patrick, do you think you are going to fix this issue?

Thank you

from django-smart-selects.

gladson avatar gladson commented on July 17, 2024

I have this same problem.

from django-smart-selects.

 avatar commented on July 17, 2024

same here.

from django-smart-selects.

davecanderson avatar davecanderson commented on July 17, 2024

I have attempted to make this work for a TabularInline by replacing the script generated by widgets.py at line 73 with;

    <script type="text/javascript">
    //<![CDATA[
    (function($) {
        function fireEvent(element,event){
            if (document.createEventObject){
            // dispatch for IE
            var evt = document.createEventObject();
            return element.fireEvent('on'+event,evt)
            }
            else{
            // dispatch for firefox + others
            var evt = document.createEvent("HTMLEvents");
            evt.initEvent(event, true, true ); // event type,bubbling,cancelable
            return !element.dispatchEvent(evt);
            }
        }

        function dismissRelatedLookupPopup(win, chosenId) {
            var name = windowname_to_id(win.name);
            var elem = document.getElementById(name);
            if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
                elem.value += ',' + chosenId;
            } else {
                elem.value = chosenId;
            }
            fireEvent(elem, 'change');
            win.close();
        }

        $(document).ready(function(){
            var re_tabular = /-__prefix__-/;

            function fill_field(val, init_value, replacement){
                if (typeof replacement == 'undefined') 
                    replacement = [''];

                var ids = "#%(id)s".replace(re_tabular,replacement[0]);

                if (!val || val==''){
                    options = '<option value="">%(empty_label)s<'+'/option>';
                    $(ids).html(options);
                    $(ids + ' option:first').attr('selected', 'selected');
                    $(ids).trigger('change');
                    return;
                }

                $.getJSON("%(url)s/"+val+"/", function(j){
                    var options = '<option value="">%(empty_label)s<'+'/option>';
                    for (var i = 0; i < j.length; i++) {
                        options += '<option value="' + j[i].value + '">' + j[i].display + '<'+'/option>';
                    }
                    var width = $(ids).outerWidth();
                    $(ids).html(options);
                    if (navigator.appVersion.indexOf("MSIE") != -1)
                        $(ids).width(width + 'px');
                    $(ids + ' option:first').attr('selected', 'selected');
                    var auto_choose = %(auto_choose)s;
                    if(init_value){
                        $(ids + ' option[value="'+ init_value +'"]').attr('selected', 'selected');
                    }
                    if(auto_choose && j.length == 1){
                        $(ids + 'option[value="'+ j[0].value +'"]').attr('selected', 'selected');
                    }
                    $(ids).trigger('change');
                })
            }

            if(!$("#id_%(chainfield)s").hasClass("chained")){
                var val = $("#id_%(chainfield)s").val();
                fill_field(val, "%(value)s");
            }

            $("#id_%(chainfield)s").change(function(){
                var replacement, is_tablular;
                is_tablular = re_tabular.test("#%(id)s");
                replacement = is_tablular ? $(this).attr('id').match(/-.*-/) || [''] : [''];

                var start_value = $("#%(id)s".replace(re_tabular,replacement[0])).val();
                var val = $(this).val();
                fill_field(val, start_value, replacement);
            })
        })
        if (typeof(dismissAddAnotherPopup) !== 'undefined') {
            var oldDismissAddAnotherPopup = dismissAddAnotherPopup;
            dismissAddAnotherPopup = function(win, newId, newRepr) {
                oldDismissAddAnotherPopup(win, newId, newRepr);
                if (windowname_to_id(win.name) == "id_%(chainfield)s") {
                    $("#id_%(chainfield)s").change();
                }
            }
        }
    })(jQuery || django.jQuery);
    //]]>
    </script> 

Seems to work ok except sometimes the $.getJSON xhr request returns an empty string which makes the j parameter undefined. This should be at least an empty array '[]' but not sure why this is happening.

from django-smart-selects.

mnayak avatar mnayak commented on July 17, 2024

Is there any update on this bug; has anyone found a solution?

from django-smart-selects.

essadek avatar essadek commented on July 17, 2024

any upadate for this issue.
I tried davecanderson patch, but when I select in the first dropdown in the new added line the second dropdown of the first line is changed not the corresponding one.

from django-smart-selects.

onyekaa avatar onyekaa commented on July 17, 2024

Would really love if we could get an update on this... having the same problem.

from django-smart-selects.

niotech avatar niotech commented on July 17, 2024

anyone got this working out yet?

from django-smart-selects.

SalahAdDin avatar SalahAdDin commented on July 17, 2024

Anyone could solve this issue? Many people have it!

from django-smart-selects.

knixeur avatar knixeur commented on July 17, 2024

I've got this working on PR #96 if you can please test it. Thanks!

from django-smart-selects.

SalahAdDin avatar SalahAdDin commented on July 17, 2024

👍

from django-smart-selects.

blag avatar blag commented on July 17, 2024

Should be fixed by #148, PyPI release inbound (today or tomorrow).

Closing, but feel free to reopen if it's not. Thanks!

from django-smart-selects.

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.