Problems with Page Selector

Permalink
If you use two page selectors or a page selector and a file selector on a page, in which you override the selection changed function, you will run in some troubles.

i solved it with a simple line of code. i copied the page_selector.php file from concrete->core->helpers->form in my custom helpers->form folder on top level. and add folowing snippet after line 82:

$("input[name=\'"+fieldName+"\']").trigger("selectionChanged", [ cID, cName ]);


so it looks like

if($javascriptFunc=='' || $javascriptFunc=='ccm_selectSitemapNode'){
   $html .= '
   var fieldName = $(ccmActivePageField).attr("dialog-sender");
   var par = $(ccmActivePageField).parent().find(\'.ccm-summary-selected-item-label\');
   $(ccmActivePageField).parent().find(\'.ccm-sitemap-clear-selected-page\').show();
   var pari = $(ccmActivePageField).parent().find("[name=\'"+fieldName+"\']");
   par.html(cName);
   pari.val(cID);
        $("input[name=\'"+fieldName+"\']").trigger("selectionChanged", [ cID, cName ]); 
   ';
}else{
   $html .= $javascriptFunc."(cID, cName); \n";
}

Now i can listen on my new event "selectionChanged" in my auto.js or form_setup_html.php like this:

$('input[name="pageSelectorId"]').on("selectionChanged", function(event, cID, cName) {
         alert(cID + " : " + cName);
});


I hope it helps somebody

Lemonbrain