willem

willem

Hi everyone. I’ve come across html code containing “phx-click” and a google search has lead me to phoenix and this forum. I hope I’m at the right place and that someone here can help me.

First off, I don’t really know Javascript, so phoenix and elixir is completely foreign to me, I don’t even know how the two relate to each other.

I’m trying to automate changing a setting on a Web app for a device in my home using phantomjs. Note I can access the http webpage of the device, but do not have any control over the html or javascript code itself. Right now the obstacle I’m trying to pass is clicking on the following link:

<a href="#" phx-click="edit_settings" phx-target="1">edit</a>

Code in my phantomjs script is:

SetTimeout(function() {
    console.log("");
    console.log("### STEP 3: Click on edit link");
    page.evaluate(function() {
        var ev = document.createEvent("MouseEvents");
        ev.initEvent("click", true, true);
        document.querySelector("#settings > div > form > div > div.full > h3 > span > a").dispatchEvent(ev);
    });
}, 6000);

I’ve also tried replacing dispatchEvent(ev) with click().

As far as I can see the correct element is selected, but the page doesn’t switch to edit mode, i.e. doesn’t respond to the click. I’ve tried tracing what happens when the link is clicked in chrome Web tools, but then too the page doesn’t respond to the click. Any suggestions on how I can get the page to switch to edit mode.

From my searches online I’ve gathered that if a link is coded with the normal on-click attribute then the phoenix stuff don’t respond or work with that code and the opposite seem to be true as well. With the link having the phx-click attribute the normal click methods and events doesn’t seem to effect the link.

Ultimately I would like phantomjs to click above mentioned edit link, change a value in a drop down box and click the save button. I believe if I can get past the first edit link obstacle I should be able to manage the rest. I’m hoping that there is perhaps something like “element.phxclick(‘edit-settings’)” that can be used to trigger the click on that edit link. Any help or suggestions would be much appreciated. Even if the solution doesn’t involve using phantomjs. As long as it is a command line command I can enter to change the setting so that I can use that in another script again. Maybe one don’t even have to simulate the click and one can somehow just send the necessary data directly to the device using a http post, but I can’t figure out how the data is sent to the device either.

Showing Posts 1 to 1

kokolegorille

kokolegorille

Hello and welcome,

Elixir and Javascript are not related, they are different language.

Phoenix is a web framework and might use Javascript.

But all phx-click are related to Liveview, which is an attempt to avoid using JS. And You need to have a Phoenix server to use it.

And phantomjs… probably You use it as an http client, to control your device.

It’s possible to manage your device from an http client, but adding Phoenix to do this is not the easiest path :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews