Closed fuatu closed 6 years ago
I don't know if this is the exact fix for this issue but I found a code modification that seems to be working for me. I changed the following function in the 'chainedfk.js' file:
$.each(j, function (index, optionData) {
var option = $('<option></option>')
.prop('value', optionData.value)
.text(optionData.display);
if (auto_choose || init_value && optionData.value == init_value) {
option.prop('selected', true);
}
options.push(option);
});
To the function below. I found via browser developer console that "true" or "false" would sometimes be a boolean and sometimes be a string which would change the logic for this function:
$.each(j, function (index, optionData) {
var option = $('<option></option>')
.prop('value', optionData.value)
.text(optionData.display);
if (auto_choose == "false" || auto_choose == "False"){
auto_choose = false;
} else if (auto_choose == "true" || auto_choose == "True"){
auto_choose = true;
}
if (auto_choose || init_value && optionData.value == init_value) {
option.prop('selected', true);
}
options.push(option);
});
I hope this helps the bug fixing efforts.
@czechmate247 Thanks for the help! I've added your patch to my PR #250.
@fuatu Please check if my personal master
branch fixes this for you and report back. If it does I'll merge it in (as mentioned above, please see PR #250 for progress on that) and cut a release to PyPI so you can install it easier in production. Thanks!
You are most welcome and thank you for implementing this so quickly! I will not be able to check your branch for a few days because I am away from my office. I don’t want to keep you from submitting the changes though so please feel free! Thanks again.
On Jan 21, 2018, at 6:40 PM, blag notifications@github.com wrote:
@czechmate247 https://github.com/czechmate247 Thanks for the help! I've added your patch to my PR #250 https://github.com/digi604/django-smart-selects/pull/250.
@fuatu https://github.com/fuatu Please check if my personal master branch https://github.com/blag/django-smart-selects fixes this for you and report back. If it does I'll merge it in (as mentioned above, please see PR #250 https://github.com/digi604/django-smart-selects/pull/250 for progress on that) and cut a release to PyPI so you can install it easier in production. Thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/digi604/django-smart-selects/issues/242#issuecomment-359292153, or mute the thread https://github.com/notifications/unsubscribe-auth/AQYLFqtgqa-YaBc8HJVIqC72SuFbgoNMks5tM8r-gaJpZM4Qy6eE.
Released to PyPI and GitHub in version 1.5.4
. Thanks!
Even auto_choose is false when there is one record it selects the record automatically both in template and in django admin.