Joel
Joined
Activity
I am still using some jQuery, but here is the stimulus controller I am using...
yes , I did. Did you have any specific questions about it?
Thanks! Do you use bootstrap and tailwind for the gorails site?
I see a postcss.config.js but no .postcssrc.yml.
Thanks! Makes me love Ruby more every time I have to jump into Javascript.
I am attempting in app notifications similar to how Chris did it in the tutorial but trying to update it to use Stimulus but i my data-target doesn't seem to be in scope in the ajax success callback. Here is the relevent code:
getNewNotes() {
Rails.ajax(
{
url: "/notes.json",
type: "GET",
success: this.handleSuccess
}
)
}
handleSuccess(data) {
const items = $.map(data, note => { return note.template })
console.log(items.length)
console.log(data[0].unread)
let unreadCount = 0
$.each(data, (i, note) => {
if (note.unread) {
unreadCount += 1
}
});
this.unreadCountTarget.innerHTML = unreadCount
}
Can anyone point me in the right direction to get this working using stimulus?
Posted in Setup MacOS 10.14 Mojave Discussion
Is the header issue for Mojave resolved? When I run the command sudo installer
command listed in the final steps I get the following error: installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
Posted in update a model attribute with ujs
i have a page that displays games(model) with a select box for the game result outcome. Game model has_one :result, autosave: true
and
I have a unique id for each row in the table based on the game id and I am using materialize rails which attaches a class of "active selected" to whichever choice is selected in the select dropdown(these correspond to the enum keys. i would like to use ujs to update the result whenever the user selects from the select dropdown. I am haven't done much with ujs in rails but it seems like it should be fairly simple. Can anyone give some guidance on how this would be setup?
result model has:
enum outcome: {
undecided: 0,
white_won: 1,
black_won: 2,
white_forfeit: 3,
black_forfeit: 4,
draw: 5,
}