page selector 5.7

Permalink 2 users found helpful

In Concrete 5.6 it was possible to create a JavaScript callback. I would like to know how this can be achieved in 5.7. I want to select a page and then do an ajax call to get the area names from that page.

//how it is done in 5.6
<?php echo $page_selector->selectPage('cTargetID', $cTargetID ? $cTargetID : 0, 'pageChange'); ?>

In Concrete 5.7 this does not seem possible. When I look in the core the third parameter does not exist anymore.
public function selectPage($fieldName, $cID = false
public function selectPage($fieldName, $cID = false, $javascriptFunc='ccm_selectSitemapNode')

-- update --

I also tried it with the ConcretePageSelector (js). But I can't find any event or callback what I can use. Core file can be found in concrete/js/build/core/sitemap/selector.js

View Replies: View Best Answer
rge replied on at Permalink Reply
Still no solution has been found. The next "logical" step was to check with JS if the field value is changed. But this event doest not get triggered. This is because the element it self is replaced (node).

Is there a reason why the callback is remove in 5.7?
rge replied on at Permalink Reply
On StackOverflow I got a tip to bind too the Concrete Event. But still I am not enable to receive the selected pageID. the console.log does not get logged.

Concrete.event.bind('SitemapSelectPage', function(data) {

$pageSelect= Core::make('helper/form/page_selector');
<?php echo $pageSelect->selectPage('displayPagesCID', $displayPagesCID); ?>
TimDix replied on at Permalink Best Answer Reply
Hello, I was trying to figure out the same thing today, your code snippet was very close, just needed the extra argument in the callback to get the data you need.

Concrete.event.bind('SitemapSelectPage', function(e, data) {

Object {cID: "507", title: "Events", instance: c}
rge replied on at Permalink Reply
Thanks for the response. For some reason the function does not get triggered add all. Even when I console.log('test'); notting gets outputted to the console. I also tried to wrap it in a document.ready but still no result.
rge replied on at Permalink Reply
Korvin Szanto has provided a fix for the not correct working SitemapSelectPage event bindings.

His explanation
Due to a current core bug, the SitemapSelectPage event bindings get cleared just before the dialog opens, to get around this we just bind to the ConcreteSitemap event and bind there.

Here's a working example
Concrete.event.bind('ConcreteSitemap', function(e, instance) {
    var instance = instance;
    Concrete.event.bind('SitemapSelectPage', function(e, data) {
        if (data.instance == instance) {
            alert("You've selected a page! " + data.cID);