So extremely weird...
I am using
<.form :let={dateFrom} phx-submit="ignore">
<%= date_input dateFrom, :date_from, [phx_change: "change_date", value: @selected_date_from] %>
<%= date_input dateFrom, :date_to, [phx_change: "change_date", value: @selected_date_to] %>
</.form>
def handle_event("change_date", %{"date_from" => string_date_from}, socket) do
chart_data_type = socket.assigns.selected_data_type
pos = socket.assigns.selected_pos
{:ok, date_from} = Date.from_iso8601(string_date_from)
{:ok, date_to} = Date.from_iso8601(socket.assigns.selected_date_to)
args = %{
queriedValue: chart_data_type,
pos: pos,
date_from: date_from,
date_to: date_to
}
{:ok, data} = MetacrisisBi.SalesRecord.Record.by_month_warehouse_sales(args)
{:noreply, socket
|> assign(selected_date_from: string_date_from)
|> push_event("update-points-date", %{points: data.datasets, labels: data.dates})}
end
If I don't do the assign the new value to selected_date_from, all works nice, ChartJS updates and all.
No errors on JS part, and nothing in server logs.
I need to update the selected_date_from as I need to use the value in some other handle_events
Any ideas?
I tried both Date type and well formated string type... weird.