Question

I'm building an app using batman.js and rails 3.2.

I would like to automatically populate this form with the current_user's id as well as the message_thread's id that this message will be added into.

<form data-formfor-message="controllers.messages.newMessage" data-event-submit="controllers.messages.create">
    <input class="new-item" placeholder="type here..." data-bind="message.body" />
    <input class="new-item" type="hidden" data-bind="message.message_thread_id" />
    <input class="new-item" type="hidden" data-bind="message.user_id" />
    <input type="submit" value="Reply" />
</form>

I've looked around for a while but haven't found anything yet. If you need more information to answer my question please ask.

Thanks!

Was it helpful?

Solution

I found there is the data-bind-value method.

<form data-formfor-message="controllers.messages.newMessage" data-event-submit="controllers.messages.create">
    <input placeholder="type here..." data-bind="message.body" />
    <input data-bind-value="message_thread.id" type="hidden" data-bind="message.message_thread_id" />
    <input data-bind-valude="currentUser.id" type="hidden" data-bind="message.user_id" />
    <input type="submit" value="Reply" />
</form>

That does the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top