Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

Getting Element-Properties

Open hvoges opened this issue 4 years ago • 3 comments

Is there a way to access the Properties of the Web-Elements? I am especially interested in the text-Input from Editor. I want to save the code-input locally on the server.

hvoges avatar Oct 26 '21 16:10 hvoges

Hey @hvoges,

Yes, you can! There's an upload button which can be added to the top of the code editor. This will give you the code in $WebEvent.Data['value'] for the upload's scriptblock.

Hope that helps

Badgerati avatar Oct 26 '21 20:10 Badgerati

Hi @Badgerati,

worked like a charm, thank you. Still, I think it would be more convenient if access would be possible in object-style like $Editor = -Name 'Editor' -Language 'powershell' -Value "myscript" <Button pushed> $Editor.Value

Just as an example for the Editor, but in fact for all Elements. This would be more Powershell or .net like. Do you think about implementing something like this in the future? Never the less, really great job that you did here! I love Pode and Pode.Web!

hvoges avatar Oct 27 '21 09:10 hvoges

That's a good idea actually, though I'd probably opt for using $self instead so it's more like .NET's $this:

New-PodeWebCard -Content @(
    New-PodeWebCodeEditor -Name 'Editor' -Language 'powershell' -Upload {
        $self.value
    }
)

That should work for most elements with scriptblocks 🤔

$self in most cases would be set internally, and likely just be something similar to $self = $WebEvent.Data. There is also an $ElementData available, which is the base configuration for the element.

Badgerati avatar Oct 27 '21 21:10 Badgerati