1

For several reasons, I need to customize the prompt shown in the list search box, i.e. the one that says "Find an item".

Is there an official way to do this, via a display template or similar?

2

Unforthenatlly, No there's not a display tmplate realted to List search box at Display Template folder within http://Sitecollection/_catalogs/masterpage/Display Templates/Search/,

But You can do this for Site Search Box, where at Sitecollection/_catalogs/masterpage/Display Templates/Search/ , there are display templates for the following search box

  • Default Search Box. (Control_SearchBox)
  • Site Search Box. (Control_SearchBox_Compact)

And You can create element.xml via visual studio to change for example the Search This Site Promoted text at InitialPrompt property

<Property Name="InitialPrompt">Search SharePoint site</Property>

Here the full example to do this Replacing the OOTB Small Search Input Box in SharePoint 2013

So for List Search Box I customize it via Javascript as the following :

<script>
    _spBodyOnLoadFunctionNames.push("changefinditem");
    function changefinditem() {
      document.getElementById("inplaceSearchDiv_WPQ2_lsinput").value = "Find Qassas";
    }

</script>

Output

enter image description here

| improve this answer | |
0

I ended up doing something very similar to the suggestion of M.Qassas above. The code looks like this:

_spBodyOnLoadFunctionNames.push("CustomizeListSearchBox");

function CustomizeListSearchBox()
{
    $(document).on('DOMNodeInserted', function(e) {
        if (e.target.id == 'inplaceSearchDiv_WPQ2_lsparent') {
            e.target.children[0].addEventListener("DOMAttrModified", function(xe) {
                e.target.children[0].value = 'Search just this list';
            }, false);
        }
    });
}

For reasons I don't understand, not only does the List Search Box get inserted into the DOM at a relatively late stage, but the prompt itself is set at an even later stage.

Consequently, what I had to do was listen for a DOMNodeInserted event, check to see it was the parent of the list search box, and then attach a listener to the list search box itself and listen for DOMAttrModified in order to be sure I could set the prompt without it being overwritten.

The code can obviously be improved, when I understand the sequence of events better.

Josh

| improve this answer | |
  • Dear @josh Great Job , Meanwhile you said I used the similar suggestion fro me But I am wondering Is my answer and workaround code not helped and working for you ? I also shared print screen from output in my environment that worked correctly ? !! and also I added more clarification about why you can't do this in display template ?! this was your question , you need to know it's possible or not ?!! I have answered this and introduced also a workaround so should you tell me why this answer is not useful for you ? thanks for your response :) – Mohamed El-Qassas MVP Sep 30 '16 at 20:24
  • To tell you the truth, I didn't see your workaround until I'd got something to work. But thanks anyway, and for the enlightenment of no display template (which I think Microsoft should remedy). – Josh Korn Sep 30 '16 at 22:46
  • thanks , I was only need to know if my answer is not correct for you or not , so please if my answer is considered an aswer to your question , should you set as answer to be useful for all , thanks for appriciating my time :) – Mohamed El-Qassas MVP Sep 30 '16 at 23:09
0

edit the Display Templates - Control_SearchBox.html file and set your text

if($isNull(prompt)){
    prompt = "Find an item";
}

see details in https://docs.microsoft.com/en-us/sharepoint/search/how-to-change-the-text-that-is-displayed-in-the-search-box-web-part

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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