❔ my string event click isn't working

im trying to include this div inside my gridData, but once i store it in shareBtnvariable it doesnot work but once i get it out of the Scripts it works normally ((all the idea is to trigger
data-kt-menu-trigger="click"
data-kt-menu-trigger="click"
which will automatically do everything) which is not triggering what is the problem
@section Scripts {
<partial name="_GridViewResourcesScript" />
<partial name="_ValidationScriptsPartial" />

<script>
$(document).ready(function () {
const dt = $('#gridData').DataTable({
"createdRow": function (row, data, index) {
// actions column
var shareBtn = `
<div class="d-flex align-items-center mx-1 mx-lg-3">
<div onclick=showShareMenu() class=" btn btn-icon web-br-circle headerImage-box p-3 w-40px h-30px w-md-40px h-md-40px"
data-kt-menu-trigger="click"
data-kt-menu-attach="parent"
data-kt-menu-placement="bottom-end"
data-kt-menu-flip="bottom">
<?xml version="1.0" encoding="UTF-8" ?>
<here is svg >
</div>
<!--begin::Menu sub (this menu should appear when clicking into svg >
<div class="menu menu-sub data-kt-menu="true">
<button id="fb" class="btn w-full">
Share Facebook
</button>
</div>
</div>`;

var btnGroup = `<div class="btn-group"> ${shareBtn} </div>`;
var table = $('#gridData').DataTable();
var cell = table.cell(index, 5);
cell.data(btnGroup);
}
},
@section Scripts {
<partial name="_GridViewResourcesScript" />
<partial name="_ValidationScriptsPartial" />

<script>
$(document).ready(function () {
const dt = $('#gridData').DataTable({
"createdRow": function (row, data, index) {
// actions column
var shareBtn = `
<div class="d-flex align-items-center mx-1 mx-lg-3">
<div onclick=showShareMenu() class=" btn btn-icon web-br-circle headerImage-box p-3 w-40px h-30px w-md-40px h-md-40px"
data-kt-menu-trigger="click"
data-kt-menu-attach="parent"
data-kt-menu-placement="bottom-end"
data-kt-menu-flip="bottom">
<?xml version="1.0" encoding="UTF-8" ?>
<here is svg >
</div>
<!--begin::Menu sub (this menu should appear when clicking into svg >
<div class="menu menu-sub data-kt-menu="true">
<button id="fb" class="btn w-full">
Share Facebook
</button>
</div>
</div>`;

var btnGroup = `<div class="btn-group"> ${shareBtn} </div>`;
var table = $('#gridData').DataTable();
var cell = table.cell(index, 5);
cell.data(btnGroup);
}
},
6 Replies
InsertPi
InsertPi15mo ago
This is a C# discord. Someone correct me if I'm wrong, but this seems like a JavaScript question?
Mohamad | Software Engineer
it's not (::
InsertPi
InsertPi15mo ago
the only code you've posted is JavaScript code though
Mohamad | Software Engineer
im working on .net project and that's it the problem is with invoking my function in cshtml file
Angius
Angius15mo ago
It's Javascript code still, jQuery to be more precise
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?