IF condition in onchange attributeLightning Component aura:iteration is throwing error upon rerenderingLightning Component - Locker Service IssueError in lightning componentAnyone successfully using numeraljs with LockerService enabled?Lightning component order of execution in inheritance problemRestaurant Locator Trailhead Project Lightning ErrorComponent Initilization Error: cannot read property 'g'Lightning component error handleOnBlur eventCannot read property 'set' of undefined when List<String> return in ui:inputSelectError with a Salesforce Lightning Component in the Utility Bar (IE11)
Why boldmath fails in a tikz node?
Who was the lone kid in the line of people at the lake at the end of Avengers: Endgame?
How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?
"The cow" OR "a cow" OR "cows" in this context
'regex' and 'name' directives in find
Like totally amazing interchangeable sister outfits II: The Revenge
Retract an already submitted recommendation letter (written for an undergrad student)
How would 10 generations of living underground change the human body?
What term is being referred to with "reflected-sound-of-underground-spirits"?
How did Captain America manage to do this?
Minor Revision with suggestion of an alternative proof by reviewer
Mistake in years of experience in resume?
How to fry ground beef so it is well-browned
How much cash can I safely carry into the USA and avoid civil forfeiture?
Are there physical dangers to preparing a prepared piano?
Which big number is bigger?
"Hidden" theta-term in Hamiltonian formulation of Yang-Mills theory
Does tea made with boiling water cool faster than tea made with boiled (but still hot) water?
Is Diceware more secure than a long passphrase?
Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?
Was there a Viking Exchange as well as a Columbian one?
Two field separators (colon and space) in awk
How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?
What causes platform events to fail to be published and should I cater for failed platform event creations?
IF condition in onchange attribute
Lightning Component aura:iteration is throwing error upon rerenderingLightning Component - Locker Service IssueError in lightning componentAnyone successfully using numeraljs with LockerService enabled?Lightning component order of execution in inheritance problemRestaurant Locator Trailhead Project Lightning ErrorComponent Initilization Error: cannot read property 'g'Lightning component error handleOnBlur eventCannot read property 'set' of undefined when List<String> return in ui:inputSelectError with a Salesforce Lightning Component in the Utility Bar (IE11)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to trigger controller method only when text box gets cleared out. I tried to use IF condition in onchange but it throws out error Uncaught Uncaught error in markup://aura:valueChange [Cannot read property 'config' of undefined]
<lightning:input type="text" name="searchBox" label="!v.searchLabel"
value ="!v.searchString" onchange ="!if(v.searchString == null,c.onEmptyInput,''"/>
I know I can just use onchange=!c.onEmptyInput and then check if searchString is null in controller method and write my logic based on that. But I want to know if IF statements can be used to call controller methods.
lightning-aura-components
add a comment |
I want to trigger controller method only when text box gets cleared out. I tried to use IF condition in onchange but it throws out error Uncaught Uncaught error in markup://aura:valueChange [Cannot read property 'config' of undefined]
<lightning:input type="text" name="searchBox" label="!v.searchLabel"
value ="!v.searchString" onchange ="!if(v.searchString == null,c.onEmptyInput,''"/>
I know I can just use onchange=!c.onEmptyInput and then check if searchString is null in controller method and write my logic based on that. But I want to know if IF statements can be used to call controller methods.
lightning-aura-components
add a comment |
I want to trigger controller method only when text box gets cleared out. I tried to use IF condition in onchange but it throws out error Uncaught Uncaught error in markup://aura:valueChange [Cannot read property 'config' of undefined]
<lightning:input type="text" name="searchBox" label="!v.searchLabel"
value ="!v.searchString" onchange ="!if(v.searchString == null,c.onEmptyInput,''"/>
I know I can just use onchange=!c.onEmptyInput and then check if searchString is null in controller method and write my logic based on that. But I want to know if IF statements can be used to call controller methods.
lightning-aura-components
I want to trigger controller method only when text box gets cleared out. I tried to use IF condition in onchange but it throws out error Uncaught Uncaught error in markup://aura:valueChange [Cannot read property 'config' of undefined]
<lightning:input type="text" name="searchBox" label="!v.searchLabel"
value ="!v.searchString" onchange ="!if(v.searchString == null,c.onEmptyInput,''"/>
I know I can just use onchange=!c.onEmptyInput and then check if searchString is null in controller method and write my logic based on that. But I want to know if IF statements can be used to call controller methods.
lightning-aura-components
lightning-aura-components
asked 8 hours ago
devforcedevforce
166215
166215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I know I can just use
onchange=!c.onEmptyInputand then check ifsearchStringisnullin controller method and write my logic based on that.
You should stick to this approach instead of using any conditional logic here. Additionally, your onchange will not even trigger if the input is empty.
With what you are trying to do, you won't be able to use a conditional statement here, as it will not work. For onchange to work, you will need to explicitly mention a controller function in format of:
onchange="!c.myFunction"
Values anything other than this format will have no effect on the event handler (I can confirm this with a quick test). In this case even if your if condition evaluates correctly (this is not correctly written though in its current form and you will get a compile time error), you will only get a value, which will not be of the same format as what is expected.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f260210%2fif-condition-in-onchange-attribute%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I know I can just use
onchange=!c.onEmptyInputand then check ifsearchStringisnullin controller method and write my logic based on that.
You should stick to this approach instead of using any conditional logic here. Additionally, your onchange will not even trigger if the input is empty.
With what you are trying to do, you won't be able to use a conditional statement here, as it will not work. For onchange to work, you will need to explicitly mention a controller function in format of:
onchange="!c.myFunction"
Values anything other than this format will have no effect on the event handler (I can confirm this with a quick test). In this case even if your if condition evaluates correctly (this is not correctly written though in its current form and you will get a compile time error), you will only get a value, which will not be of the same format as what is expected.
add a comment |
I know I can just use
onchange=!c.onEmptyInputand then check ifsearchStringisnullin controller method and write my logic based on that.
You should stick to this approach instead of using any conditional logic here. Additionally, your onchange will not even trigger if the input is empty.
With what you are trying to do, you won't be able to use a conditional statement here, as it will not work. For onchange to work, you will need to explicitly mention a controller function in format of:
onchange="!c.myFunction"
Values anything other than this format will have no effect on the event handler (I can confirm this with a quick test). In this case even if your if condition evaluates correctly (this is not correctly written though in its current form and you will get a compile time error), you will only get a value, which will not be of the same format as what is expected.
add a comment |
I know I can just use
onchange=!c.onEmptyInputand then check ifsearchStringisnullin controller method and write my logic based on that.
You should stick to this approach instead of using any conditional logic here. Additionally, your onchange will not even trigger if the input is empty.
With what you are trying to do, you won't be able to use a conditional statement here, as it will not work. For onchange to work, you will need to explicitly mention a controller function in format of:
onchange="!c.myFunction"
Values anything other than this format will have no effect on the event handler (I can confirm this with a quick test). In this case even if your if condition evaluates correctly (this is not correctly written though in its current form and you will get a compile time error), you will only get a value, which will not be of the same format as what is expected.
I know I can just use
onchange=!c.onEmptyInputand then check ifsearchStringisnullin controller method and write my logic based on that.
You should stick to this approach instead of using any conditional logic here. Additionally, your onchange will not even trigger if the input is empty.
With what you are trying to do, you won't be able to use a conditional statement here, as it will not work. For onchange to work, you will need to explicitly mention a controller function in format of:
onchange="!c.myFunction"
Values anything other than this format will have no effect on the event handler (I can confirm this with a quick test). In this case even if your if condition evaluates correctly (this is not correctly written though in its current form and you will get a compile time error), you will only get a value, which will not be of the same format as what is expected.
edited 8 hours ago
answered 8 hours ago
Jayant DasJayant Das
19.5k21331
19.5k21331
add a comment |
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f260210%2fif-condition-in-onchange-attribute%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown