Weird problem with dependent list fields

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 19, 2012   (RSS)

Re: [garyhoffmann] Weird problem with dependent list fields

By Jason - April 19, 2012

Hi,

You're right, this is a bug in the CMS that we've only just recently run into. There is a fix in place for the next version of CMS Builder (2.15). The fix is currently out in the Beta Version. If you like, you can sign up as a beta tester and upgrade your CMS to the 2.15 beta. That should take care of this problem. Here is some more information about the beta:
http://www.interactivetools.com/forum/gforum.cgi?post=92938#92938

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Weird problem with dependent list fields

Since this is for a production site, I'd prefer not to use beta software on it.

Any ability to give me a diffs listing or at least a pointer in the right direction that would fix it for 2.14?

Re: [garyhoffmann] Weird problem with dependent list fields

By Jason - April 19, 2012

Hi,

No problem.

You can put this fix into your current version. Make sure you make a backup of your data/files before attempting a custom change, just in case.

Get this file:
cmsAdmin\lib\menus\default\edit_functions.js

About half way through the code, you'll find a function called updateListFieldOptions(). Replace that function with the following code:

//
function updateListFieldOptions(fieldname, newFilterValue) {

// show "loading..." in the pulldown we're going to update
$("[name='" +fieldname+ "']").html("<option value=''>Loading...</option>\n");

// update pulldown options

// Get the current value of the pulldown we're about to update
var selectedValue = $("[name='" +fieldname+ "']").val();

// Uncomment to see what the values discovered/passed are
//alert("update '" +fieldname+ "' with new filter value '" +newFilterValue+ "' and selected Value: '" +selectedValue+ "'");


$.ajax({
// Added false on sync to allow each ajax request to complete before the next one fires off
// this prevents interference if more than one pulldown depends on a select.change event.
//async: false, // v2.15 uncomment this line if it's needed for future versions, moving change event inside success block should be enough.
url: '?',
type: "POST",
data: {
menu: $('#menu').val(),
fieldname: fieldname,
newFilterValue: newFilterValue,
selectedValue: selectedValue,
action: 'ajaxUpdateListFieldOptions'
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert("There was an error sending the request! (" +XMLHttpRequest['status']+" "+XMLHttpRequest['statusText'] +")");
},
success: function(html){
// show errors
if (!html.match(/^<option/)) { alert("Error: " + html); }

// update list options
$("[name='" +fieldname+ "']").html(html); // for single pulldowns
$("[name='" +fieldname+ "\\[\\]']").html(html); // for multi-pulldowns

// fire change event on this field so any child chained selects will also update
$("[name='" +fieldname+ "']").change();
}
});



}


That should take care of the problem for you.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Weird problem with dependent list fields

Thank you - just an FYI - I needed to uncomment the async: false to get it to work correctly. Otherwise, the results were identical.

Thanks again.
Gary.