Comments (17)
Any news? Thanks!
from django-smart-selects.
I'm going to be trying to come up with a solution for this in the near future..... hopefully tomorrow!
from django-smart-selects.
Any news on this bug ? Thanks ;)
from django-smart-selects.
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.
I have this problem, too.
from django-smart-selects.
Me too.
Patrick, do you think you are going to fix this issue?
Thank you
from django-smart-selects.
I have this same problem.
from django-smart-selects.
same here.
from django-smart-selects.
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.
Is there any update on this bug; has anyone found a solution?
from django-smart-selects.
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.
Would really love if we could get an update on this... having the same problem.
from django-smart-selects.
anyone got this working out yet?
from django-smart-selects.
Anyone could solve this issue? Many people have it!
from django-smart-selects.
I've got this working on PR #96 if you can please test it. Thanks!
from django-smart-selects.
👍
from django-smart-selects.
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)
- When I edit the form again, the contents of the chained appear empty HOT 3
- how to use django_export_import lib import django_smart_selects chainfileids?
- how to use smart-selects for a many to many field against a foreign key selection in django admin?
- Not working if primary key value of related object is 0 (zero) HOT 1
- Error with add new Inline form - ChainedForeignKey HOT 1
- ChainedManytoManyField not working with inline forms
- It doesn't work when I change the admin path HOT 3
- Actually doesnt support django version 4 HOT 11
- How to use it with pytest and create factories
- [idea] : Adding kw/arg 'display_model_col' to ChainedForeignKey et al.
- Option for removing already selected values in ChainedForeignKey field
- Django smart selects doesn't work with JS cloning
- Empty results when accessing field in `chained_field`. HOT 5
- ChainedSelectMultiple doesn't update de css extra attrs
- Chaining not working in inlines in ChainedManyToManyField with horizontal=True parameter HOT 1
- Cannot set queryset for Chainedforeignkey
- ChainedModelChoiceField.choices initialization incompatibility with Django 5.0 HOT 10
- Publish latest package version to PyPi HOT 1
- Empty dropdown for chained field HOT 1
- jQuery URL docs is misleading and not aligned with that is actually done
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-smart-selects.