Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Removed external dependencies #4

Closed
wants to merge 2 commits into from

2 participants

Michał Poręba Lucas Martin
Michał Poręba

The code had dependencies on cog.utils but only one function was used from there cog.string.startsWith.
You wound't notice lack of cog.utils.js until you wanted to use function as a data source anyway.

So to avoid surprises and unnecessary dependencies I replaced your custom function with ko.utils.stringStartsWith. After all it is supposed to be a knockout extensions, isn't it ;)

I hope you approve this small simplification.

michalporeba added some commits
Michał Poręba michalporeba Fix for DataTables 1.9.0 beta
Signed-off-by: Michal Poreba <michalporeba@gmail.com>
fb5d5ae
Michał Poręba michalporeba Removed dependency on cog.utils
Signed-off-by: Michal Poreba <michalporeba@gmail.com>
05a1009
Michał Poręba

Well, again two commits in one request... I'll have to read how it all works before I submit another one ;)

Lucas Martin
Owner

Heya Michal,

The intention of separating out the utility functions in a separate cog.utils.js file was purely for separation of concerns. What I was going to do was create a build script which would join all of the js files together and into one big js file and minify the script so you wouldn't have to worry about including dependencies. For this reason I wont be accepting this pull request, but I will however work on a build script to solve this problem.

As for the other change you made, I'll pull that one into the source.

Lucas Martin ducka closed this
Michał Poręba

sure build script will remove dependency but not the redundancy. At the moment only one function is used and the same function is already available in ko.utils. But it is your call after all.

Lucas Martin
Owner

Ahh, I see. No worries, I'll have a look at that.

Lucas Martin ducka reopened this
Lucas Martin ducka closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 6, 2012
  1. Michał Poręba

    Fix for DataTables 1.9.0 beta

    michalporeba authored
    Signed-off-by: Michal Poreba <michalporeba@gmail.com>
  2. Michał Poręba

    Removed dependency on cog.utils

    michalporeba authored
    Signed-off-by: Michal Poreba <michalporeba@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +8 −8 Javascript/src/knockout.bindings.dataTables.js
16 Javascript/src/knockout.bindings.dataTables.js
View
@@ -42,7 +42,7 @@ ko.bindingHandlers['dataTable'] = {
if (binding.rowTemplate && binding.rowTemplate != '') {
options.fnRowCallback = function (row, data, displayIndex, displayIndexFull) {
// Render the row template for this row.
- ko.renderTemplate(binding.rowTemplate, data, null, row, "replaceChildren");
+ ko.renderTemplate(binding.rowTemplate, data, null, row, "replaceChildren");
return row;
}
}
@@ -97,7 +97,7 @@ ko.bindingHandlers['dataTable'] = {
});
// Add the new data back into the data table.
- dataTable.fnAddData(unwrappedItems);
+ dataTable.fnAddData(unwrappedItems, true);
});
}
@@ -128,8 +128,8 @@ ko.bindingHandlers['dataTable'] = {
// Insert the cell in the current row.
destRow.append(newCell);
// bind the cell to the observable in the current data row.
- var accesor = eval("srcData['" + columnName.replace(".", "']['") + "']");
- ko.applyBindingsToNode(newCell[0], { text: accesor }, srcData);
+ var accesor = eval("srcData['" + columnName.replace(".", "']['") + "']");
+ ko.applyBindingsToNode(newCell[0], { text: accesor }, srcData);
});
return destRow[0];
@@ -203,13 +203,13 @@ ko.bindingHandlers['dataTable'] = {
destOptions.RecordsToTake = item.value;
else if (item.name == "sSearch")
destOptions.GlobalSearchText = item.value;
- else if (cog.string.startsWith(item.name, "bSearchable_"))
+ else if (ko.utils.stringStartsWith(item.name, "bSearchable_"))
destOptions.Columns[colIndex].IsSearchable = item.value;
- else if (cog.string.startsWith(item.name, "sSearch_"))
+ else if (ko.utils.stringStartsWith(item.name, "sSearch_"))
destOptions.Columns[colIndex].SearchText = item.value;
- else if (cog.string.startsWith(item.name, "mDataProp_"))
+ else if (ko.utils.stringStartsWith(item.name, "mDataProp_"))
destOptions.Columns[colIndex].ColumnName = item.value;
- else if (cog.string.startsWith(item.name, "iSortCol_")) {
+ else if (ko.utils.stringStartsWith(item.name, "iSortCol_")) {
destOptions.Columns[item.value].IsSorted = true;
destOptions.Columns[item.value].SortOrder = colIndex;
Something went wrong with that request. Please try again.