문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top