javascript - Get table row ID after dropzone event - Stack Overflow

I've been banging my head on this for hours so hopefully someone can help. I'm trying to fetc

I've been banging my head on this for hours so hopefully someone can help. I'm trying to fetch either the row id or the form id when a file is uploaded into a dropzone box. I have multiple table rows with multiple dropzone boxes.

Here is an example row from my table:

<table class="docs" id="show">      
    <tr class="doc" id="*Need_This*">
        <td>
            <div class="file_upload drop">
                <form class="dropzone clickable" id="*Or_Need_This*">
                </form>
            </div>
        </td>
    </tr>
</table>

Here is my jquery:

<script type="text/javascript">
$(document).ready(function(){
     $(".dropzone").dropzone({ 
        paramName: 'photos',
        url: "post.php",
        dictDefaultMessage: "Drag or Click",
        clickable: true,
        enqueueForUpload: true,
        init: function() {
            var id = $(this).closest('tr').attr('id');
            this.on("success", function(file) { alert(id); });
          }
    });
});
</script>

Right now it's returning undefined. I need to get the id's so that I can append css changes to other elements on the row. Any help is greatly appreciated!

I've been banging my head on this for hours so hopefully someone can help. I'm trying to fetch either the row id or the form id when a file is uploaded into a dropzone box. I have multiple table rows with multiple dropzone boxes.

Here is an example row from my table:

<table class="docs" id="show">      
    <tr class="doc" id="*Need_This*">
        <td>
            <div class="file_upload drop">
                <form class="dropzone clickable" id="*Or_Need_This*">
                </form>
            </div>
        </td>
    </tr>
</table>

Here is my jquery:

<script type="text/javascript">
$(document).ready(function(){
     $(".dropzone").dropzone({ 
        paramName: 'photos',
        url: "post.php",
        dictDefaultMessage: "Drag or Click",
        clickable: true,
        enqueueForUpload: true,
        init: function() {
            var id = $(this).closest('tr').attr('id');
            this.on("success", function(file) { alert(id); });
          }
    });
});
</script>

Right now it's returning undefined. I need to get the id's so that I can append css changes to other elements on the row. Any help is greatly appreciated!

Share Improve this question asked Apr 16, 2013 at 17:32 johnjohn 1,3304 gold badges21 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

this in your case refers to the Dropzone instance, not the element itself! If you need to access the actual element of your dropzone, use dropzone.element.

So you can do: var id = $(this.element).etc....

Hope that helped.

In the documentation you can read :

Gets the server response as second argument

Try with this :

this.on("success", function(file,rep) {
     alert(file);
     alert(rep); //The response
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745180068a4615378.html

相关推荐

  • javascript - Get table row ID after dropzone event - Stack Overflow

    I've been banging my head on this for hours so hopefully someone can help. I'm trying to fetc

    3小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信