Skip to content

Add class on input , example : datepicker usage#19

Open
robiinho wants to merge 1 commit intoCraftingGamerTom:developfrom
robiinho:patch-1
Open

Add class on input , example : datepicker usage#19
robiinho wants to merge 1 commit intoCraftingGamerTom:developfrom
robiinho:patch-1

Conversation

@robiinho
Copy link

@robiinho robiinho commented Jun 10, 2021

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant