F
Filamentβ€’15mo ago
Mark Chaney

Run Action from Javascript.

Unfortunately cant just use wire:click since this is within javascript, so im forced to use a Livewire:emit and then my listener looks like so
public function showProperty($propertyId)
{
// ViewPropertyAction::class
ray($propertyId);
$property = Property::find($propertyId);
return $this->mountAction('view_property')
->record($property);

}
public function showProperty($propertyId)
{
// ViewPropertyAction::class
ray($propertyId);
$property = Property::find($propertyId);
return $this->mountAction('view_property')
->record($property);

}
. Now the problem is that the action isnt actually used anywhere on the page, which i think is part of the problem. I know its not as simple as returning my actual action with the record as that doesnt actually execute it. I think im close. But missing something simple.
6 Replies
Mark Chaney
Mark ChaneyOPβ€’15mo ago
Seems a little dirty, but this appears to work. Well kinda, its launching it, but I think im getting some conflict that the modal isnt showing. I have filament modals in my blde though. At least progress though and definitely open to improvements
public function showPropertyAction()
{
return ViewPropertyAction::make('showPropertyAction')
->record($this->property);
}

public function showProperty($propertyId)
{
$this->property = Property::find($propertyId);

return $this->mountAction('showPropertyAction');
}
public function showPropertyAction()
{
return ViewPropertyAction::make('showPropertyAction')
->record($this->property);
}

public function showProperty($propertyId)
{
$this->property = Property::find($propertyId);

return $this->mountAction('showPropertyAction');
}
hmm, looking at the html source, it may or may not have created multiple modals and why i am only seeing the shadow affect over the page I lied on the multiple modals. Must be related to other actions or something woo hoo, got it im still open to your suggestions for improvement though @Hugh Messenger i saw you typing πŸ˜›
cheesegrits
cheesegritsβ€’15mo ago
Can you explain a little more the "within javascript" part?
Mark Chaney
Mark ChaneyOPβ€’15mo ago
<script></script>
cheesegrits
cheesegritsβ€’15mo ago
So not an Alpine component?
Mark Chaney
Mark ChaneyOPβ€’15mo ago
correct. bascially the "tooltip" that mapbox is generating has a setHtml() option and i can set some html in there, but thats all done through that javascript. I am going to feel dumb here if its possible, but i dont think i can setup alpine within it
cheesegrits
cheesegritsβ€’15mo ago
My Maps widget has an example of mounting an action directly from JS using $wire.mountAction(). But there's some Alpine magic going on. Or rather, Livewire magic. But I have no idea how your component is structured, or how you use Mapbox.
Want results from more Discord servers?
Add your server