One way to do this would be to include a link (<a
href="www.google.com">Google</a>) in a table cell with a class (so you
can find it) in your HTML. Then, when the page loads, grab the URL
from the href attribute of the link, and remove the table cell
containing the link. This way you get very good marks in the
unobtrusive area: the URL is available in case JavaScript isn't on (or
jQuery doesn't load for some reason), and they get an improved
experience with JavaScript and jQuery.

Glad to see someone interested in unobtrusive scripting, 'tis the
right way to go. :)

On Nov 8, 10:26 am, Brad F <[EMAIL PROTECTED]> wrote:
> I'm trying to figure out the best way to pass variables into jQuery
> using unobtrusive javascript...
>
> For example:
>
> Clicking a column row takes you to a URL.
>         <table>
>                 <tr class="addNavigation" id="http://www.google.com";>
>                         <td>blah</td>
>                 </tr>
>         </table>
>
> ---
>
>         $("tr.addNavigation").click(function() {
>                         window.location=$(this).attr("id");
>                         return false;
>                 });
>
> As you can see, this uses the ID tag of the TR element but this is not
> a very good solution.  What if two rows go to the same URL?  Then I'm
> breaking a major rule with ID's (that they shouldn't be duplicated
> across a page)...
>
> Anyone have any ideas as I'm fairly new to jQuery and completely
> unobtrusive code.

Reply via email to