I try to update hx-post attribute but It doesnt work and the form is send without url
<button
class="conversation-btn"
data-conversation-name="{{ conversation }}"
hx-get="/conversation/{{conversation}}"
hx-swap="innerHTML"
hx-target="#content"
mustache-array-template="foo"
onclick="storeConversationName(this)">
{{conversation}}
</button>
<script>
function storeConversationName(button) {
var conversationName = button.getAttribute('data-conversation-name');
console.log('Conversation Name:', conversationName);
document.getElementById('conversation_name').value = conversationName;
document.getElementById('conversationForm').setAttribute('hx-post', '/conversation/' + conversationName);
}
</script>
Currently this code works fine and in the console i can see the Conversation Name
But the problem is with the next part of this function where i try to update attribute hx-post
As you can see here the form is send without specified url
INFO: 127.0.0.1:59760 – “POST / HTTP/1.1” 405 Method Not Allowed
<form id="conversationForm" hx-post="">
<input type="hidden" id="conversation_name" name="conversation_name">
<label for="user_input">Write query</label>
<input type="text" id="user_input" name="user_input">
</form>
I also have hidden input which can store conversationName and it works fine <input type="hidden" id="conversation_name" name="conversation_name">
but the only problem is with hx-post attribute
I tried to use htmx.process() but i don’t know how to use it correctly in my html file