When the user presses enter on a text field or presses a button I want the search to execute.
However if I set param name="allowSoftSubmit" or param name="allowAutoSubmit" to either True or False it appears that either the button doesn't work or pressing enter in a text field doesn't work. Only one of them will work at a time.
It appears that if you use Javascript to generate a search there are issues in the upstream flow.
If you want enter key in the textfield to submit the search then you definitely want <param name="allowSoftSubmit">True</param>
.
allowAutoSubmit
won't enter into any of this - that param only concerns behavior when the page first loads and there's an autoRun="True" upstream.
But if you're ever seeing the Button click itself not work, then something else is going on. Can you post the XML for the whole view? I'm not sure. I would make sure that you're refreshing the XML in between changes (via the freshmaker in Utils itself is easiest).
No, I'm just talking about how to write a reliable customBehavior. Sorry, i wasn't talking about the Search module or anything in the XML just then.
When you say the search key should always have an object do you mean customSearch because this is what I am passing to the search module.
It's easy to write a customBehavior that appears to work in some ways, but breaks the page in other ways. I would use macro(s) to do your repetitive search language and not use a customBehavior for this. You can also post the whole customBehavior and I can advise.
But in general, for the use case you have here, overriding getModifiedContext is correct, but make sure you never hit any exceptions, make sure in all cases you return a context object, and make sure that context object always has a Search object in the "search" key.
But again, I do not recommend a customBehavior here.
Could it be possible that it has something to do with this.
Sideview.utils.declareCustomBehavior("gen_search", function(module) {
module.getModifiedContext = function() {
I'm not sure if it has to do with the getModifiedContext. I tried with onContextChange but still doesn't work.
The reason I am using the CustomBehavior is because I wrote a really long search and it is sort of repetitive. The Javascript is creating the search for me so it is easier to maintain and view. The JS always worked but it was always running before the user entered any input. I added a button to make the view wait before searching.
Also if press enter the search will go, it just doesn't work for the button... the first time. What I mean is that after pushing enter for the first search the button starts to work for all other searches. Just doesn't want to work the first time.
Well I'm afraid that it's probably a problem in the 'gen_search' customBehavior. If that custom javascript you have there is causing a Javascript error, that would disrupt the whole page and that would explain why the Button click stops working sometimes. It's also a little strange that you're using the SearchMode module here. But anyway, remove the CustomBehavior temporarily and I bet your problem goes away. What are you using that for?