smartcomponents icon indicating copy to clipboard operation
smartcomponents copied to clipboard

SmartPasteButton - Use outside the form

Open spib opened this issue 1 year ago • 1 comments
trafficstars

Hi

This is awesome, thanks so much for putting this together.

My question is would it be possible to put the button outside the form tag and then add an attribute to tell it which for to use?

<smart-paste-button default-icon form=“myform” />

Our use case is that the button would ideally be positioned on the page above the form

spib avatar Mar 22 '24 16:03 spib

Yes, that seems reasonable.

In the short term, you could work around this by putting the smart paste button inside the form, but using CSS to hide it (display: none). Then add a completely separate button into the page above the form, and script it so that when the user clicks it, it behaves as if the smart paste button was clicked, e.g.:

<button onclick="document.getElementById('my-smart-paste-button').click()">Smart Paste</button>

<form>
    <SmartPasteButton id="my-smart-paste-button" style="display:none" />
</form>

Of course, you could do it without the inline script in onclick in other ways, but hopefully you get the idea.

SteveSandersonMS avatar Mar 22 '24 16:03 SteveSandersonMS