Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22397827
table-add-button.stimulus.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1019 B
Referenced Files
None
Subscribers
None
table-add-button.stimulus.ts
View Options
/// <reference lib="dom" />
import
{
Controller
}
from
"stimulus"
;
export
default
class
extends
Controller
{
static
targets
=
[
"textarea"
];
defaultRowsNumber
=
20
;
addRow
()
{
const
template
=
this
.
element
.
closest
(
"turbo-frame"
)
?
.
querySelector
(
"template"
);
if
(
!
template
)
{
throw
new
Error
(
"Couldn't find template"
);
}
const
tbody
=
this
.
element
.
closest
(
"turbo-frame"
)
?
.
querySelector
(
"tbody"
);
if
(
!
tbody
)
{
throw
new
Error
(
"tbody not found"
);
}
const
orig_template
=
template
.
innerHTML
;
const
placeholder
=
this
.
element
.
getAttribute
(
"data-table-placeholder"
);
if
(
!
placeholder
)
{
throw
new
Error
(
"Could find placeholder attribute"
);
}
template
.
innerHTML
=
orig_template
.
replaceAll
(
placeholder
,
String
(
tbody
.
querySelectorAll
(
"tr"
).
length
)
);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
tbody
.
appendChild
((
template
.
cloneNode
(
true
)
as
any
).
content
);
template
.
innerHTML
=
orig_template
;
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 17:16 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200194
Default Alt Text
table-add-button.stimulus.ts (1019 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline