All Apps and Add-ons

button not working

dgadjov
Explorer

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.

Tags (1)

dgadjov
Explorer

It appears that if you use Javascript to generate a search there are issues in the upstream flow.

0 Karma

sideview
SplunkTrust
SplunkTrust

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).

sideview
SplunkTrust
SplunkTrust

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.

0 Karma

dgadjov
Explorer

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.

0 Karma

sideview
SplunkTrust
SplunkTrust

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.

0 Karma

dgadjov
Explorer

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.

0 Karma

dgadjov
Explorer

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.

0 Karma

sideview
SplunkTrust
SplunkTrust

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?

0 Karma

dgadjov
Explorer


ids
Run IDs:

fast

Search
True
False

gen_search

$customSearch$
I have added the relevant code.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...