Add class on input , example : datepicker usage#19
Open
robiinho wants to merge 1 commit intoCraftingGamerTom:developfrom
Open
Add class on input , example : datepicker usage#19robiinho wants to merge 1 commit intoCraftingGamerTom:developfrom
robiinho wants to merge 1 commit intoCraftingGamerTom:developfrom
Conversation
My usage: bootstrap + tablesorter + datepicker + bstable , Aim : edit with picker or classes on input, verifying value, picker....
I have a table displayed using tablesorter (ajax query), some column are "date's inputs". tbody is filled with ajax.
example : <table><thead></thead><tbody></tbody><tfoot></tfoot></table>
When success, i called : editableTable.refresh(); to enable this script in tablesorter.js.
As try, i wanted to add a date picker when editing on an input.
To realise that , bstables.js generate input form. To be able to aim them with jquery, and enable datepicker.js on those inputs i needed to add classes, but where? TH seems to be the best way. So I've done it with in my html code I've added <th bstable-class="date"> in <thead>
To get this value , i add those modifications :
let th = $td.closest('table').find('th').eq($td.index());
let th_class = th.attr("bstable-class");
+
let input = '<input class="form-control input-sm '+th_class+'" data-original-value="' + content + '" value="' + content + '">';
Then i needed after edit (inputs created) to call:
$('.date').each(function () {
$(this).datepicker({});
=> callbackOnEdit: function() {}, // Called after editing (editing button clicked)
+
this.table.find('tbody tr #bEdit').each(function() {let button = this; button.onclick = function() {_this._rowEdit(button); _this.options.callbackOnEdit();} });
With this modification, i can add class on inputs when editing based on the attr in <th> column bstable-class="XXXX"
So now, when i click on the edit button, and click on an input aimed to be a date, i can display a datepicker.
I hope this is a little best explained than in the issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My usage: bootstrap + tablesorter + datepicker + bstable , Aim : edit with picker or classes on input, verifying value, picker....
I have a table displayed using tablesorter (ajax query), some column are "date's inputs". tbody is filled with ajax.
example :
<table><thead></thead><tbody></tbody><tfoot></tfoot></table>When success, i called : editableTable.refresh(); to enable this script in tablesorter.js.
As try, i wanted to add a date picker when editing on an input.
To realise that , bstables.js generate input form. To be able to aim them with jquery, and enable datepicker.js on those inputs i needed to add classes, but where? TH seems to be the best way. So I've done it with in my html code I've added
<th bstable-class="date"> in <thead>To get this value , i add those modifications :
Then i needed after edit (inputs created) to call:
=>
With this modification, i can add class on inputs when editing based on the attr in
<th> column bstable-class="XXXX"So now, when i click on the edit button, and click on an input aimed to be a date, i can display a datepicker.
I hope this is a little best explained than in the issue.