Is it possible to pass parameters to js controller in lwc2019 Community Moderator ElectionLWC-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
Diode in opposite direction?
How much character growth crosses the line into breaking the character
What linear sensor for a keyboard?
Can I use my Chinese passport to enter China after I acquired another citizenship?
Divine apple island
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
What is this type of notehead called?
Did arcade monitors have same pixel aspect ratio as TV sets?
Is XSS in canonical link possible?
Do Legal Documents Require Signing In Standard Pen Colors?
How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?
Is a model fitted to data or is data fitted to a model?
A social experiment. What is the worst that can happen?
Translation of Scottish 16th century church stained glass
How do I implement a file system driver driver in Linux?
Why has "pence" been used in this sentence, not "pences"?
Could solar power be utilized and substitute coal in the 19th Century
What does this horizontal bar at the first measure mean?
When quoting, must I also copy hyphens used to divide words that continue on the next line?
Should I stop contributing to retirement accounts?
Is it improper etiquette to ask your opponent what his/her rating is before the game?
Did US corporations pay demonstrators in the German demonstrations against article 13?
If a character with the Alert feat rolls a crit fail on their Perception check, are they surprised?
Will adding a BY-SA image to a blog post make the entire post BY-SA?
Is it possible to pass parameters to js controller in lwc
2019 Community Moderator ElectionLWC-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
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 yesterday
Lance ShiLance Shi
7,51133076
7,51133076
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 yesterday
sfdcfoxsfdcfox
261k12207452
261k12207452
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