Is it possible to pass parameters to js controller in lwc Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsLWC-Jest installation failsIs it possible to pass parameter to javascript method from template in LWC?LWC: Text Area Property ConfigurationAjax request in LWCForce refresh view in LWCJquery UI draggableImport ES modules in LWCLWC: Picklist without knowing recordTypeIdLWC: Attaching event Listener Programmatically not workingUsing Wired Property in LWC
How do I determine if the rules for a long jump or high jump are applicable for Monks?
What is the musical term for a note that continously plays through a melody?
Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?
Gastric acid as a weapon
Can Pao de Queijo, and similar foods, be kosher for Passover?
"Seemed to had" is it correct?
Is high blood pressure ever a symptom attributable solely to dehydration?
Are my PIs rude or am I just being too sensitive?
How to motivate offshore teams and trust them to deliver?
Why is "Captain Marvel" translated as male in Portugal?
What's the purpose of writing one's academic bio in 3rd person?
Is 1 ppb equal to 1 μg/kg?
What does the "x" in "x86" represent?
I am not a queen, who am I?
How to find all the available tools in macOS terminal?
Is there a Spanish version of "dot your i's and cross your t's" that includes the letter 'ñ'?
How can I make names more distinctive without making them longer?
If Jon Snow became King of the Seven Kingdoms what would his regnal number be?
What is a Meta algorithm?
Disable hyphenation for an entire paragraph
Storing hydrofluoric acid before the invention of plastics
Why is "Consequences inflicted." not a sentence?
What are the pros and cons of Aerospike nosecones?
How discoverable are IPv6 addresses and AAAA names by potential attackers?
Is it possible to pass parameters to js controller in lwc
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsLWC-Jest installation failsIs it possible to pass parameter to javascript method from template in LWC?LWC: Text Area Property ConfigurationAjax request in LWCForce refresh view in LWCJquery UI draggableImport ES modules in LWCLWC: Picklist without knowing recordTypeIdLWC: Attaching event Listener Programmatically not workingUsing Wired Property in LWC
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to implement a drag and drop functionality in lwc and I am getting the below code:
<template for:each=leftTask for:item="task">
<div class="draggable" draggable="true" key=task.taskId ondragstart=handleDragStart(task.taskId)>task.name</div>
</template>
However, it seems that lwc doesn't allow passing parameters directly into handle functions. So the above code won't work. I am wondering is it possible to pass any parameter into js handler at all? Or do I have to make a separate child component in order to handle this?
lightning-web-components
add a comment |
I am trying to implement a drag and drop functionality in lwc and I am getting the below code:
<template for:each=leftTask for:item="task">
<div class="draggable" draggable="true" key=task.taskId ondragstart=handleDragStart(task.taskId)>task.name</div>
</template>
However, it seems that lwc doesn't allow passing parameters directly into handle functions. So the above code won't work. I am wondering is it possible to pass any parameter into js handler at all? Or do I have to make a separate child component in order to handle this?
lightning-web-components
add a comment |
I am trying to implement a drag and drop functionality in lwc and I am getting the below code:
<template for:each=leftTask for:item="task">
<div class="draggable" draggable="true" key=task.taskId ondragstart=handleDragStart(task.taskId)>task.name</div>
</template>
However, it seems that lwc doesn't allow passing parameters directly into handle functions. So the above code won't work. I am wondering is it possible to pass any parameter into js handler at all? Or do I have to make a separate child component in order to handle this?
lightning-web-components
I am trying to implement a drag and drop functionality in lwc and I am getting the below code:
<template for:each=leftTask for:item="task">
<div class="draggable" draggable="true" key=task.taskId ondragstart=handleDragStart(task.taskId)>task.name</div>
</template>
However, it seems that lwc doesn't allow passing parameters directly into handle functions. So the above code won't work. I am wondering is it possible to pass any parameter into js handler at all? Or do I have to make a separate child component in order to handle this?
lightning-web-components
lightning-web-components
asked Mar 23 at 12:07
Lance ShiLance Shi
7,59233077
7,59233077
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can read data directly from the target:
<div data-id=task.taskId class="draggable" draggable="true" key=task.taskId
ondragstart=handleDragStart>task.name</div>
function handleDragStart(event)
var taskId = event.target.dataset.id;
// ...
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%2f255011%2fis-it-possible-to-pass-parameters-to-js-controller-in-lwc%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
You can read data directly from the target:
<div data-id=task.taskId class="draggable" draggable="true" key=task.taskId
ondragstart=handleDragStart>task.name</div>
function handleDragStart(event)
var taskId = event.target.dataset.id;
// ...
add a comment |
You can read data directly from the target:
<div data-id=task.taskId class="draggable" draggable="true" key=task.taskId
ondragstart=handleDragStart>task.name</div>
function handleDragStart(event)
var taskId = event.target.dataset.id;
// ...
add a comment |
You can read data directly from the target:
<div data-id=task.taskId class="draggable" draggable="true" key=task.taskId
ondragstart=handleDragStart>task.name</div>
function handleDragStart(event)
var taskId = event.target.dataset.id;
// ...
You can read data directly from the target:
<div data-id=task.taskId class="draggable" draggable="true" key=task.taskId
ondragstart=handleDragStart>task.name</div>
function handleDragStart(event)
var taskId = event.target.dataset.id;
// ...
answered Mar 23 at 12:28
sfdcfoxsfdcfox
265k13212459
265k13212459
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%2f255011%2fis-it-possible-to-pass-parameters-to-js-controller-in-lwc%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