0

Working on Sitecore 9.3.

What I'm trying to do is edit a base .js file, being component-search-url.js.

Specifically, I want to update the setEndpoint function to always return the endpoint. Currently it's possible return url += endpoint;

I've had a look at documentation but I can't seem to find the best method to approach this. I don't want to edit the base theme file because of future updates, so I want to create a js file in my new theme to update this function. But I'm just not sure how? Any help would be appreciated!

setEndpoint: function (endpoint) { 
    var url = window.location.origin;

    if (endpoint.indexOf(url) !== -1) {
       return endpoint;
    }

    return url += endpoint;
}, 

1 Answer 1

1

If that would be a JS file connected to any of the search renderings then there is a small chance that you would be able to do it. There is an option to use before and after rendering initialization functions. But in this case, I'm afraid you won't be able to do it. You can update it in the base theme but, as you wrote, you will need to update it with every SXA update.

Try a different approach... Clone rendering where you need that change, update the view (a CSS class name) so that your custom script from your theme will jump in and do the magic you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.