Open andyhmltn opened 11 years ago
The send button worked in mine - simple fix, (would fix it myself but Git is being iffy on my OS atm). Since the button is a <submit>
(<button>
defaults to type='submit'
) there are three fixes: change the <button>
s type attribute to 'button' (<button type="button"
), return false
from the callback function in $('button').click()
or pass an event
parameter to the .click()
method and then call event.preventDefault()
. This will stop it from submitting the form. I like to combine all three strategies. Eg:
JavaScript:
$('button').click(function(event) {
event.preventDefault();
// code
return false;
});
HTML:
<button type="button">Send!</button>
Very true. Although, I'm just figuring out how to do it the ember way :p
This seems to be the kind of thing that is needed: http://stackoverflow.com/questions/11985787/how-to-get-input-value-in-ember-js-app
Interesting...
Ahh that wasn't the one I saw earlier: http://stackoverflow.com/questions/8682172/trigger-an-action-in-a-text-field-from-a-button
Derp. EmberJS's handlebars has an {{action}}
helper that calls a method.
<script type="text/x-handlebars" data-template-name="message">
<textarea></textarea>
<button {{action "send"}}>Send!</button>
</script>
App.MessageController = Ember.ObjectController.extend({
send: function() {
socket.emit('sendmessage', options);
}
});
I really wish EmberJS had better docs... I'm resorting to listening to a podcast to find out more about action
options.
Sadly yes. Although, I have an idea how to do this. I just need to get around to doing it.
Currently the send button just submits a form to nowhere.