sergiopello / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

aoTableActions - last array element overwrites all other table actions #134

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. 
http://jquery-datatables-editable.googlecode.com/svn-history/r287/trunk/table-ac
tions.html
2. Click on the actions (Edit Browser, Edit Platform) in the Edit column
3. Notice that the modal dialog title always reads "Add Browser 1" (not "Update 
Browser" or "Update Platforms", as specified in the title attribute of the 
forms). It looks like the last element of aoTableActions always overwrites the 
other elements of the array, making it impossible to use multiple actions and 
multiple forms.

What is the expected output? What do you see instead?
The modal dialog title should change to ""Update Browser" or "Update 
Platforms", depending on which action is invoked.

What version of the product are you using? On what operating system?
See the source code of the example

Please provide any additional information below.

Original issue reported on code.google.com by albel...@gmail.com on 18 Oct 2012 at 4:22

GoogleCodeExporter commented 9 years ago
Shouldn't the code in click event handler for oTableActions be like following 

File : jQuery.datatable.editable.js

<code>

if (oActionFormLink.length != 0) {

                            oActionFormLink.live("click", function () {

                                var sClass = this.className;
                                var classList = sClass.split(/\s+/);
                                var sActionFormId = "";
                                var sAction = "";
                                for (i = 0; i < classList.length; i++) {
                                    if (classList[i].indexOf("table-action-") > -1) {
                                        sAction = classList[i].replace("table-action-", "");
                                        sActionFormId = "#form" + sAction;
                                    }
                                }
                                if (sActionFormId == "") {
                                    properties.fnShowError("Cannot find a form with an id " + sActionFormId + " that should be associated to the action - " + sAction, sAction)
                                }

                                var oTableAction = $(sActionFormId).data("action-options");

                                if (oTableAction.sType == "edit") {

                                    //var oTD = ($(this).parents('td'))[0];
                                    var oTR = ($(this).parents('tr'))[0];
                                    fnPopulateFormWithRowCells(oActionForm, oTR);
                                }
                                oActionForm = $(sActionFormId);// I added this line. Before this everytime the "oActionForm" object used to be overwritten with the last aoTableActions (array's) last action
                                $(oActionForm).dialog('open');
                            });
                        }

</code>

Original comment by akshay.b...@gmail.com on 3 Jun 2014 at 10:53