- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2016 06:53 AM
Hello,
I have a contextual search, when a user searches it gives a list of "record producers". The user wants to simple click on the link and it should take him to the required 'record producer'.
So I want to get rid of this button "Take Me To Form" [which does the right job, but want the url link before it to do the job]
I have searched everywhere in the contextual search and record producers, but cannot locate this "Take Me To Form" button.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2016 04:58 AM
Hi Andy.
You can get rid of the button with a catalog client script. Please be aware though, when you upgrade, there may be changes to Contextual Search could break your script. You'll be able to see if we've changed anything in contextual search in the release notes though.
This is the script:
function onLoad() {
document.observe("cxs:target_update", function() {
$$("#cxs_results_container button.request_catalog_button_with_icon").each(function(elem, index) {
elem.hide();
});
});
}
The event cxs:target_update is fired each time a search is completed.
This is what my catalog client script looks like:
This will only work on your record producer. If you wanted to do hide the Order button when displaying contextual search results on a form you would need to create an onLoad client script there too. The however should be the same.
Let me know if this works for you.
Thanks,
Cameron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 03:55 AM
Hi Andy,
No problem .
This should do exactly what you want. Take the action that is performed when clicking the Order button and make the original link do that instead. I've added comments inline:
$$("#cxs_results_container a.service_catalog").each(function(elem, index) {
var orderButtons = elem.adjacent(".request_catalog_button_with_icon");
if (orderButtons.length == 0)
return;
var orderButton = orderButtons[0];
orderButton.hide();
elem.on("click", function(){
event.stop(); // Stop the event from bubbling and from performing its default action
window.location = orderButton.readAttribute("data-url"); // Change the windows location to the hidden button's URL
});
});
That should do it. Let me know if you have any issues.
Thanks,
Cameron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 12:58 PM
That was brilliant -THANK YOU!
I put the brackets to complete your code, it all works as expected. Have a great day!
--------------------------------------------------------------------------------------------
function onLoad() {
document.observe("cxs:target_update", function() {
$$("#cxs_results_container a.service_catalog").each(function(elem, index) {
var orderButtons = elem.adjacent(".request_catalog_button_with_icon");
if (orderButtons.length == 0)
return;
var orderButton = orderButtons[0];
orderButton.hide();
elem.on("click", function(){
event.stop(); // Stop the event from bubbling and from performing its default action
window.location = orderButton.readAttribute("data-url"); // Change the windows location to the hidden button's URL
});
});
});
}
--------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 02:16 AM
Hi Cameron,
While this works fine on a Chrome, the url takes me to the pop-up in the firefox [its probably ignoring that the url needs to direct to the target page instead of the pop-up].
Will the script work on non-chrome browser or do I need to do any tweaks to it?
I have done a 'cache.do', logged-out n logged-in, anything more I need to do?
Thanks in Advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 02:21 AM
I further checked in both mac/windows it works fine on IE, Safari *not* on firefox 😕 strange.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 02:45 AM
I'm looking at it for you now. The event.stop() isn't acting in the same way that it does in Chrome.
Give me a sec, I'll get it sorted