I have in my index.html.erb
page a dropdown list of the English alphabet, A->Z, with a Select All
option. My parser takes specific words from a .txt
and displays the words in the index page. I want to organize the page after a letter is selected with only words beginning with that letter.
I am new to Rails; with that in mind, I want to use AJAX so that the information just gets displayed on the same page.
With these in mind, I am not sure how best to progress; using JavaScript, erb, etc. As of now I currently have no code implemented and I am looking for ideas.
link_to "A", index_path(letter: "A"), remote: true
@words = Word.where("word ILIKE ?", "#{params[:letter]}%")
respond_to { |format| format.js }
respond_to { |format| format.js }
index.js.erb
, render the words into the page: $("#wordlist").html("<%= escape_javascript(render('words', words: @words)) %>");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.