page selector 5.7
Permalink 2 users found helpful
Hi,
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.
In Concrete 5.7 this does not seem possible. When I look in the core the third parameter does not exist anymore.
-- 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
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.
//5.7 public function selectPage($fieldName, $cID = false //5.6 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
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.
auto.js
form.php
auto.js
Concrete.event.bind('SitemapSelectPage', function(data) { console.log(data); });
form.php
$pageSelect= Core::make('helper/form/page_selector'); <?php echo $pageSelect->selectPage('displayPagesCID', $displayPagesCID); ?>
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.
Result:
Concrete.event.bind('SitemapSelectPage', function(e, data) { console.log(data); });
Result:
Object {cID: "507", title: "Events", instance: c}
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.
Korvin Szanto has provided a fix for the not correct working SitemapSelectPage event bindings.
http://stackoverflow.com/questions/29647943/page-selector-block-dev...
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
http://stackoverflow.com/questions/29647943/page-selector-block-dev...
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) { Concrete.event.unbind(e); alert("You've selected a page! " + data.cID); } }); });
Is there a reason why the callback is remove in 5.7?