1

I have a litte problem with selecting a table row with specific class and a specific data attribute.

I hope anyone has an idea.

This is the HTML source

    <table id="source" class="connectedSource" width="100%">
    <thead>
    ...
    <tbody>
    ...
    <tr class="headrow" bgcolor="#c2c2c2">
    ...
    <tr data-obj_id="904" class="datarow ui-draggable" bgcolor="#ffffff">
    ...
    <tr data-obj_id="906" class="datarow ui-draggable" bgcolor="#ffffff">
    ...
    <tr data-obj_id="908" class="datarow ui-draggable" bgcolor="#ffffff">
    ...
    <tr data-obj_id="903" class="datarow ui-draggable" bgcolor="#efefef">
    ...

This works fine ...

    if ($.browser.mozilla) console.log('selector = ' + "tbody tr.datarow");
    if ($.browser.mozilla) console.log('source row class = ' + $("#source").find("tbody tr.datarow").attr('class'));
    if ($.browser.mozilla) console.log('source row obj_id = ' + $("#source").find("tbody tr.datarow").data('obj_id'));

The result ...

    selector = tbody tr.datarow
    source row class = datarow ui-draggable
    source row obj_id = 904

This doesn't work ...

    if ($.browser.mozilla) console.log('selector = ' + "tbody tr.datarow[data-obj_id='" + source_obj_id + "']");
    if ($.browser.mozilla) console.log('source row class = ' + $("#source").find("tbody tr.datarow[data-obj_id='" + source_obj_id + "']").attr('class'));
    if ($.browser.mozilla) console.log('source row obj_id = ' + $("#source").find("tbody tr.datarow[data-obj_id='" + source_obj_id + "']").data('obj_id'));

The result ...

    selector = tbody tr.datarow[data-obj_id='875']
    source row class = undefined
    source row obj_id = undefined

I have to select the datarow with data-obj_id = 908

I hope anyone can help ...

Thanx

Talki

1

1 Answer 1

3

since your obj_id is unique.. i don't think you need class selector there

try with

 "tbody tr[data-obj_id='" + source_obj_id + "']"
Sign up to request clarification or add additional context in comments.

3 Comments

The Result = selector = tbody tr[data-obj_id='908'] source row class = undefined source row obj_id = undefined
make sure your source_obj_id is correct... working example jsfiddle.net/bipen/MgZFA
oh my goodness ... i found my problem ... ther are 2 tables (source and destination) ... it works with drag and drop ... if object is dropped on destination table, the object in source was removed ... that was the only problem ... thanx for help ... Talki

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.