Refreshing cascading dropdown when a new value is added

Eabz

New Member
I'm using userAjax to insert a row in another table on the click of a button. However, I need a cascading dropdown to automatically refresh once the ajax has run. Is this possible and if not is there a work around that would produce similar results?
 
Here's my element JS:

JavaScript:
function generateInvestigation(aid, progress, request, category, title, prior, des, device, inc_date, inc_st, inc_et,camera)
{
  var url = 'index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=addInvestigation&aid='
            +aid+'&progress='+progress+'&request='+request+'&category='+category+'&title='+title+'&prior='
            +prior+'&des='+des+'&device='+device+'&inc_date='+inc_date+'&inc_st='+inc_st+'&inc_et='+inc_et+'&camera='+camera;
  new Request({url:url,
               method:'get',
               update:document.id('videos___video_investigation_id')
  }).send();
 
}

/* get element values using js */
...
/* function to dynamically generate an investigation using element values */
generateInvestigation(aid, progress, request, category, title, prior, des, device, inc_date, inc_st, inc_et, camera);
 
OK, you'll need to use an onComplete function instead of update, so you can run some other code.

JavaScript:
function generateInvestigation(aid, progress, request, category, title, prior, des, device, inc_date, inc_st, inc_et,camera)
{
  var url = 'index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=addInvestigation&aid='
            +aid+'&progress='+progress+'&request='+request+'&category='+category+'&title='+title+'&prior='
            +prior+'&des='+des+'&device='+device+'&inc_date='+inc_date+'&inc_st='+inc_st+'&inc_et='+inc_et+'&camera='+camera;
  new Request({url:url,
               method:'get',
               onComplete: function(result) {
                     var form = Fabrik.getBlock('form_X');
                     var watchedEl = form.formElements.get('videos___video_investigation_id');
                     watchedEl.update(result);
                     watchedEl.element.fireEvent('change', new Event.Mock(watchedEll.element, 'change'));
              }
  }).send();

}

I'm assuming that the videos___video_investigation_id element you are updating is the join element that your CDD is watching.

Replace X in form_X with your numeric form ID.

-- hugh
 
Oh, and depending what your AJAX returns, you may need to change it to just return the value you want to set the element to. I can't remember offhand if the update function expects just a value, or a formatted DOM element.

-- hugh
 
There is a CDD watching another CDD that is watching a join. The new value has to appear as an option in the CDD (the on that is watching the other CDD). So I changed the get element to the one that it needed and the update(result) to update(aid) and that got it to work as needed.

JavaScript:
onComplete: function(result) {
                     var form = Fabrik.getBlock('form_X');
                     var watchedEl = form.formElements.get('videos___amount_id');
                     watchedEl.update(aid);
                     watchedEl.element.fireEvent('change', new Event.Mock(watchedEll.element, 'change'));
              }

Thanks a lot for the help!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top