Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » JQuery closest('tr') won't work

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1696 Views
  • sergieboy
    Avatar
    Community Member
    33 Posts

    JQuery closest('tr') won't work Link to this post

    I have a table and when I click on a row, the childrows are opened in accordeon style with JQuery.
    All works fine. But the only thing is, I want the accordeon to open a the level of the row I clicked.
    Therefore, the function closest() is used. But this won't work.
    My childtable always opens at the button of the mastertable...

    I use the JQuery 1.6.4, so that can not be the problem.

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: JQuery closest('tr') won't work Link to this post

    Doesn't closest() travel up the tree? If so, it wouldn't open a child table. Maybe next() would work..

    Anyway - not really a SilverStripe question

  • sergieboy
    Avatar
    Community Member
    33 Posts

    Re: JQuery closest('tr') won't work Link to this post

    100% SS question.
    I'm playing around with the JTable in SS. Really cool thing to work with.
    All works fine, but there's just one thing I can't get right :
    open the child table at the height of the parent table.

    http://www.codeproject.com/Articles/277576/AJAX-based-CRUD-tables-using-ASP-NET-MVC-3-and-jTa

    I suppose it's the SS framework and the way the page gets rendered. In ASP no problem.

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: JQuery closest('tr') won't work Link to this post

    Well, you didn't say that, did you? : -) You just said you had a table (somewhere), you click a row (= tr in my book) and closest() doesn't get you that same row (tr) - which it wouldn't, when you're clicking the row itself...

    I suppose you're referring to something like this (from the jTable demo's):

    $img.click(function () {
       $('#StudentTableContainer').jtable('openChildTable',
          $img.closest('tr'),
          { ...

    clicking this image inside a cell should definitelyget you the encompassing tr. Still: I don't see how this is a SilverStripe issue, unless of course you are trying to use this in the backend - or using some other interfering javascript on your frontend?

    1696 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.