1. salvator
  2. django-admintools-bootstrap
  3. Issues
Issue #37 new

jquery chosen inline select problem

cisarpavel
created an issue

Got same problem as in ticket #13. After add new item displayed select not working. Got latest git version.

Comments (2)

  1. cisarpavel reporter

    hot fix by running following js on desired page. my case is changeform page with product user inlines. removing added chosen select and new initialization of chosen helps.

    jQuery(document).ready(function(){
        setTimeout(function(){
            jQuery(".add-row a").click(function(event){
                var row = jQuery(".dynamic-productusers");
                var col = row.find(".field-user");
                var select = col.find("select");
                select.removeClass("chzn-done");
                col.find(".chzn-container").remove();
                select.chosen();
            });
        }, 1000);
    })
    
  2. Mr Snow

    I've had the same problem. Thanks for the fix! I've abstracted it away from specific inlines and fields. One thing I don't like in my version is the dependence on the 'td' tag. Here goes.

    jQuery(document).ready(function(){
        setTimeout(function(){
            jQuery(".add-row a").click(function(event){
                jQuery(this).closest(".add-row").siblings().each(function() {
                //  this should be the dynamic set (dynamic-inlinemodelname_set)
                  if ( jQuery(this).attr('class')
                                   .match(/\bdynamic\-.*_set\b/) ) {
                    var select = jQuery(this).find("select.chzn-done");
                    //  undo chosen
                    select.removeClass("chzn-done")
                          .parents("td").find(".chzn-container").remove();
                    //  reapply chosen
                    select.chosen();
                  }
                })
            });
        }, 1000);
    });
    
  3. Log in to comment