I have a website with multiple pages that are shown in order, so I have a ‘continue’ button on the bottom of each page. I wanted my site to automatically scroll to the bottom to show the continue button when the user was finished with the page. I imagine there are many ways to do this, but here’s what worked for me. I knew how to scroll to a certain element on the page:
So this is pretty basic, but it took me 10 minutes of Googling to figure it out. If you need to specifically assign a value to a form input, here is how to do it via coffeescript:
$(".submit").on "click", -> email = $('input[name="user[email]"]').val(); $('.hiddenEmail').val(email);
The key is the
.val()method. To get the value of an element, you call the
.val()method without passing in…
This may not be super common, but it was hard to debug for me. I had an error when I was posting form parameters using the .post_form method from one rails app to another, where a nested params hash was getting html escaped and ending up with tons of slashes or backslashes appearing in the params hash, like this:
I’ve just recently started learning how to use the jQuery UI framework. Seems very useful, and although I haven’t personally tested yet, supposedly has good cross browser support.
I use the jQuery UI dialog boxon my site. I’ll write another post about how to customize them completely, but in this case I just wanted to remove the close “X” in the upper right corner that comes in the dialog box by…
I was trying to figure out how to create a confirmation alert dialog in coffeescript. Turns out like almost everything in coffeescript, its super easy.
$(".mybutton").on "click", -> if confirm "Ask a question?" # if answer yes else # if answer no
Sometimes you want to center the columns when using Bootstrap. I was using only like 3 columns of varying sizes, but I wanted to get them centered. So here’s how I did it, with all credit going to minimit and this article.
.row-centeredclass to your rows and the
.col-centeredclass to the columns in your html.
And here’s the css for those classes:
/* centered columns styles */…
Prawn is a pdf generator built in ruby, that is pretty full featured. However, I found it pretty hard to find good current documentation on using it in Rails. Much of it was years old, and referred to older versions of prawn and older versions of Rails. Ryan Bates’ RailsCast #153 was very helpful though, as usual.
Fortunately, there is a gem we can use:
And of course run
Now I don’t fully understand the asset pipeline and if/how it was involved in this error, but here’s what worked for me.
Simply manually precompile assets prior to pushing to heroku:
bundle exec rake assets:precompile