I’m having trouble wrapping my head around the proper syntax to have
jQuery (in an .js file) grab an HTML attribute and use the value of
that attribute to load a partial.
This isn’t possible. Whatever is in your <%= %> bits is evaluated when
the response is served by your browser. It can’t use information that
will only come into existence once the user has started to interact
with the page in the browser. You’d either need to have all those
partials hidden somewhere on the page so that the js can find them or
make an Ajax request once you know which partial is needed.
This isn’t possible. Whatever is in your <%= %> bits is evaluated when
the response is served by your browser.
Wrong(a typo?). The way it works is:
The browser makes a request.
The server prepares the response, and evaluates the <% … %> bits.
The server sends the response to the browser.
The browser takes action based on the response.
The browser certainly doesn’t evaluate the <% … %> bits.
It can’t use information that
will only come into existence once the user has started to interact
with the page in the browser. You’d either need to have all those
partials hidden somewhere on the page so that the js can find them or
make an Ajax request once you know which partial is needed.
The link does send an ajax request–that is what the attribute: