Display Partner information JavaScript file using jQuery











up vote
0
down vote

favorite












In my application display partner detail on front side using jQuery datatable.
I have written JavaScript code with common declaring variable for accessing id and classes for selector.



var partnerList =
{
urls: {
srcPartnerList: '/partner/getpartnerlist',
srcViewOffer: "/partner/viewoffer/",
srcUpdateCountPartnerOffserView: "/partner/updatecountpartneroffserview",
srcDefultLogoimage: ""
},

variables: {
oTable: null,
srchKey: 'srchParams',
logoImageHeight: "150px",
logoImageWidth: "150px"
},

controls: {
tblPartnerList: $("#tblPartnerList"),
searchText: "#searchText",
btnSearch: "#btnSearch",
divPartnerContentDetail: "#partnercontentdetail"
},

initDatatable: function () {
oTable = partnerList.controls.tblPartnerList.dataTable({
"sDom": "frtip",
"ordering": false,
"processing": true,
"serverSide": true,
"sAjaxSource": partnerList.urls.srcPartnerList,
"aaSorting": [[0, "asc"]],
"bLengthChange": true,
"filter": false,
"aoColumnDefs": [
{
"aTargets": [0],
"visible": false,
},
{
"aTargets": [1],
"mRender": function (data, type, full) {
return partnerList.renderLogo(full[0], full[1]);
},
"bSortable": false
},
{
"aTargets": [2],
},
{
"aTargets": [3],
"visible": true,
"mRender": function (data, type, full) {
return partnerList.renderClickable(full[0]);
},
"bSortable": false
}],
"oLanguage": {
"sEmptyTable": "No offer(s) available",
"sLengthMenu": "Page Size: _MENU_",
"oPaginate": {
"sFirst": "<<",
"sLast": ">>",
"sNext": ">",
"sPrevious": "<"
}
},
"fnServerParams": function (aoData) {
var srchParams = $("div").data("srchParams");
if (srchParams) {
for (var i = 0; i < srchParams.length; i++) {
aoData.push({ "name": "" + srchParams[i].name + "", "value": "" + srchParams[i].value + "" });
}
}
}
});
},

reload: function () {
oTable.dataTable().fnClearTable(0);
oTable.dataTable().fnStandingRedraw();
},

reset: function () {
$("div").removeData(partnerList.variables.srchKey);
partnerList.reload();
},

renderClickable: function (partnerID, partnerName) {
var view = `<a title="View Offer" onclick="partnerList.partnerOfferCountView(${partnerID})" class="btn btn-xs btn-primary" href="${partnerList.urls.srcViewOffer}${partnerID}">View Offer</a>`;
return view;
},

renderLogo: function (partnerID, logoUrl) {
var image = "";
if (logoUrl != "") {
//"onerror="this.src=''""
image = `<a onclick="partnerList.partnerOfferCountView(${partnerID})" href="${partnerList.urls.srcViewOffer}${partnerID}"><img src='${logoUrl}' style='height:${partnerList.variables.logoImageHeight};width:${partnerList.variables.logoImageWidth
};'></a>`;
}
return image;
}
}


My document ready function:



$(document).ready(function () {

partnerList.initDatatable();

$(partnerList.controls.searchText).keypress(function (e) {
if (e.keyCode == 13) {
if ($(this).val().trim() != '') {
$("div").removeData(partnerList.variables.srchKey);
$("div").data("srchParams",
[{ name: 'srchTxt', value: encodeURIComponent($(this).val().trim()) }]
);
partnerList.reload();
}
else {
partnerList.reset();
}
}
});

$(partnerList.controls.btnSearch).click(function (e) {
if ($(partnerList.controls.searchText).val().trim() != '') {
$("div").removeData(partnerList.variables.srchKey);
$("div").data("srchParams",
[{ name: 'srchTxt', value: encodeURIComponent($(partnerList.controls.searchText).val().trim()) }]
);
partnerList.reload();
}
else {
partnerList.reset();
}
});
});


I have written a variable partnerList and in controls add all its selectors. Is there any good way to write a script file, and any suggestions for me?










share|improve this question




























    up vote
    0
    down vote

    favorite












    In my application display partner detail on front side using jQuery datatable.
    I have written JavaScript code with common declaring variable for accessing id and classes for selector.



    var partnerList =
    {
    urls: {
    srcPartnerList: '/partner/getpartnerlist',
    srcViewOffer: "/partner/viewoffer/",
    srcUpdateCountPartnerOffserView: "/partner/updatecountpartneroffserview",
    srcDefultLogoimage: ""
    },

    variables: {
    oTable: null,
    srchKey: 'srchParams',
    logoImageHeight: "150px",
    logoImageWidth: "150px"
    },

    controls: {
    tblPartnerList: $("#tblPartnerList"),
    searchText: "#searchText",
    btnSearch: "#btnSearch",
    divPartnerContentDetail: "#partnercontentdetail"
    },

    initDatatable: function () {
    oTable = partnerList.controls.tblPartnerList.dataTable({
    "sDom": "frtip",
    "ordering": false,
    "processing": true,
    "serverSide": true,
    "sAjaxSource": partnerList.urls.srcPartnerList,
    "aaSorting": [[0, "asc"]],
    "bLengthChange": true,
    "filter": false,
    "aoColumnDefs": [
    {
    "aTargets": [0],
    "visible": false,
    },
    {
    "aTargets": [1],
    "mRender": function (data, type, full) {
    return partnerList.renderLogo(full[0], full[1]);
    },
    "bSortable": false
    },
    {
    "aTargets": [2],
    },
    {
    "aTargets": [3],
    "visible": true,
    "mRender": function (data, type, full) {
    return partnerList.renderClickable(full[0]);
    },
    "bSortable": false
    }],
    "oLanguage": {
    "sEmptyTable": "No offer(s) available",
    "sLengthMenu": "Page Size: _MENU_",
    "oPaginate": {
    "sFirst": "<<",
    "sLast": ">>",
    "sNext": ">",
    "sPrevious": "<"
    }
    },
    "fnServerParams": function (aoData) {
    var srchParams = $("div").data("srchParams");
    if (srchParams) {
    for (var i = 0; i < srchParams.length; i++) {
    aoData.push({ "name": "" + srchParams[i].name + "", "value": "" + srchParams[i].value + "" });
    }
    }
    }
    });
    },

    reload: function () {
    oTable.dataTable().fnClearTable(0);
    oTable.dataTable().fnStandingRedraw();
    },

    reset: function () {
    $("div").removeData(partnerList.variables.srchKey);
    partnerList.reload();
    },

    renderClickable: function (partnerID, partnerName) {
    var view = `<a title="View Offer" onclick="partnerList.partnerOfferCountView(${partnerID})" class="btn btn-xs btn-primary" href="${partnerList.urls.srcViewOffer}${partnerID}">View Offer</a>`;
    return view;
    },

    renderLogo: function (partnerID, logoUrl) {
    var image = "";
    if (logoUrl != "") {
    //"onerror="this.src=''""
    image = `<a onclick="partnerList.partnerOfferCountView(${partnerID})" href="${partnerList.urls.srcViewOffer}${partnerID}"><img src='${logoUrl}' style='height:${partnerList.variables.logoImageHeight};width:${partnerList.variables.logoImageWidth
    };'></a>`;
    }
    return image;
    }
    }


    My document ready function:



    $(document).ready(function () {

    partnerList.initDatatable();

    $(partnerList.controls.searchText).keypress(function (e) {
    if (e.keyCode == 13) {
    if ($(this).val().trim() != '') {
    $("div").removeData(partnerList.variables.srchKey);
    $("div").data("srchParams",
    [{ name: 'srchTxt', value: encodeURIComponent($(this).val().trim()) }]
    );
    partnerList.reload();
    }
    else {
    partnerList.reset();
    }
    }
    });

    $(partnerList.controls.btnSearch).click(function (e) {
    if ($(partnerList.controls.searchText).val().trim() != '') {
    $("div").removeData(partnerList.variables.srchKey);
    $("div").data("srchParams",
    [{ name: 'srchTxt', value: encodeURIComponent($(partnerList.controls.searchText).val().trim()) }]
    );
    partnerList.reload();
    }
    else {
    partnerList.reset();
    }
    });
    });


    I have written a variable partnerList and in controls add all its selectors. Is there any good way to write a script file, and any suggestions for me?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      In my application display partner detail on front side using jQuery datatable.
      I have written JavaScript code with common declaring variable for accessing id and classes for selector.



      var partnerList =
      {
      urls: {
      srcPartnerList: '/partner/getpartnerlist',
      srcViewOffer: "/partner/viewoffer/",
      srcUpdateCountPartnerOffserView: "/partner/updatecountpartneroffserview",
      srcDefultLogoimage: ""
      },

      variables: {
      oTable: null,
      srchKey: 'srchParams',
      logoImageHeight: "150px",
      logoImageWidth: "150px"
      },

      controls: {
      tblPartnerList: $("#tblPartnerList"),
      searchText: "#searchText",
      btnSearch: "#btnSearch",
      divPartnerContentDetail: "#partnercontentdetail"
      },

      initDatatable: function () {
      oTable = partnerList.controls.tblPartnerList.dataTable({
      "sDom": "frtip",
      "ordering": false,
      "processing": true,
      "serverSide": true,
      "sAjaxSource": partnerList.urls.srcPartnerList,
      "aaSorting": [[0, "asc"]],
      "bLengthChange": true,
      "filter": false,
      "aoColumnDefs": [
      {
      "aTargets": [0],
      "visible": false,
      },
      {
      "aTargets": [1],
      "mRender": function (data, type, full) {
      return partnerList.renderLogo(full[0], full[1]);
      },
      "bSortable": false
      },
      {
      "aTargets": [2],
      },
      {
      "aTargets": [3],
      "visible": true,
      "mRender": function (data, type, full) {
      return partnerList.renderClickable(full[0]);
      },
      "bSortable": false
      }],
      "oLanguage": {
      "sEmptyTable": "No offer(s) available",
      "sLengthMenu": "Page Size: _MENU_",
      "oPaginate": {
      "sFirst": "<<",
      "sLast": ">>",
      "sNext": ">",
      "sPrevious": "<"
      }
      },
      "fnServerParams": function (aoData) {
      var srchParams = $("div").data("srchParams");
      if (srchParams) {
      for (var i = 0; i < srchParams.length; i++) {
      aoData.push({ "name": "" + srchParams[i].name + "", "value": "" + srchParams[i].value + "" });
      }
      }
      }
      });
      },

      reload: function () {
      oTable.dataTable().fnClearTable(0);
      oTable.dataTable().fnStandingRedraw();
      },

      reset: function () {
      $("div").removeData(partnerList.variables.srchKey);
      partnerList.reload();
      },

      renderClickable: function (partnerID, partnerName) {
      var view = `<a title="View Offer" onclick="partnerList.partnerOfferCountView(${partnerID})" class="btn btn-xs btn-primary" href="${partnerList.urls.srcViewOffer}${partnerID}">View Offer</a>`;
      return view;
      },

      renderLogo: function (partnerID, logoUrl) {
      var image = "";
      if (logoUrl != "") {
      //"onerror="this.src=''""
      image = `<a onclick="partnerList.partnerOfferCountView(${partnerID})" href="${partnerList.urls.srcViewOffer}${partnerID}"><img src='${logoUrl}' style='height:${partnerList.variables.logoImageHeight};width:${partnerList.variables.logoImageWidth
      };'></a>`;
      }
      return image;
      }
      }


      My document ready function:



      $(document).ready(function () {

      partnerList.initDatatable();

      $(partnerList.controls.searchText).keypress(function (e) {
      if (e.keyCode == 13) {
      if ($(this).val().trim() != '') {
      $("div").removeData(partnerList.variables.srchKey);
      $("div").data("srchParams",
      [{ name: 'srchTxt', value: encodeURIComponent($(this).val().trim()) }]
      );
      partnerList.reload();
      }
      else {
      partnerList.reset();
      }
      }
      });

      $(partnerList.controls.btnSearch).click(function (e) {
      if ($(partnerList.controls.searchText).val().trim() != '') {
      $("div").removeData(partnerList.variables.srchKey);
      $("div").data("srchParams",
      [{ name: 'srchTxt', value: encodeURIComponent($(partnerList.controls.searchText).val().trim()) }]
      );
      partnerList.reload();
      }
      else {
      partnerList.reset();
      }
      });
      });


      I have written a variable partnerList and in controls add all its selectors. Is there any good way to write a script file, and any suggestions for me?










      share|improve this question















      In my application display partner detail on front side using jQuery datatable.
      I have written JavaScript code with common declaring variable for accessing id and classes for selector.



      var partnerList =
      {
      urls: {
      srcPartnerList: '/partner/getpartnerlist',
      srcViewOffer: "/partner/viewoffer/",
      srcUpdateCountPartnerOffserView: "/partner/updatecountpartneroffserview",
      srcDefultLogoimage: ""
      },

      variables: {
      oTable: null,
      srchKey: 'srchParams',
      logoImageHeight: "150px",
      logoImageWidth: "150px"
      },

      controls: {
      tblPartnerList: $("#tblPartnerList"),
      searchText: "#searchText",
      btnSearch: "#btnSearch",
      divPartnerContentDetail: "#partnercontentdetail"
      },

      initDatatable: function () {
      oTable = partnerList.controls.tblPartnerList.dataTable({
      "sDom": "frtip",
      "ordering": false,
      "processing": true,
      "serverSide": true,
      "sAjaxSource": partnerList.urls.srcPartnerList,
      "aaSorting": [[0, "asc"]],
      "bLengthChange": true,
      "filter": false,
      "aoColumnDefs": [
      {
      "aTargets": [0],
      "visible": false,
      },
      {
      "aTargets": [1],
      "mRender": function (data, type, full) {
      return partnerList.renderLogo(full[0], full[1]);
      },
      "bSortable": false
      },
      {
      "aTargets": [2],
      },
      {
      "aTargets": [3],
      "visible": true,
      "mRender": function (data, type, full) {
      return partnerList.renderClickable(full[0]);
      },
      "bSortable": false
      }],
      "oLanguage": {
      "sEmptyTable": "No offer(s) available",
      "sLengthMenu": "Page Size: _MENU_",
      "oPaginate": {
      "sFirst": "<<",
      "sLast": ">>",
      "sNext": ">",
      "sPrevious": "<"
      }
      },
      "fnServerParams": function (aoData) {
      var srchParams = $("div").data("srchParams");
      if (srchParams) {
      for (var i = 0; i < srchParams.length; i++) {
      aoData.push({ "name": "" + srchParams[i].name + "", "value": "" + srchParams[i].value + "" });
      }
      }
      }
      });
      },

      reload: function () {
      oTable.dataTable().fnClearTable(0);
      oTable.dataTable().fnStandingRedraw();
      },

      reset: function () {
      $("div").removeData(partnerList.variables.srchKey);
      partnerList.reload();
      },

      renderClickable: function (partnerID, partnerName) {
      var view = `<a title="View Offer" onclick="partnerList.partnerOfferCountView(${partnerID})" class="btn btn-xs btn-primary" href="${partnerList.urls.srcViewOffer}${partnerID}">View Offer</a>`;
      return view;
      },

      renderLogo: function (partnerID, logoUrl) {
      var image = "";
      if (logoUrl != "") {
      //"onerror="this.src=''""
      image = `<a onclick="partnerList.partnerOfferCountView(${partnerID})" href="${partnerList.urls.srcViewOffer}${partnerID}"><img src='${logoUrl}' style='height:${partnerList.variables.logoImageHeight};width:${partnerList.variables.logoImageWidth
      };'></a>`;
      }
      return image;
      }
      }


      My document ready function:



      $(document).ready(function () {

      partnerList.initDatatable();

      $(partnerList.controls.searchText).keypress(function (e) {
      if (e.keyCode == 13) {
      if ($(this).val().trim() != '') {
      $("div").removeData(partnerList.variables.srchKey);
      $("div").data("srchParams",
      [{ name: 'srchTxt', value: encodeURIComponent($(this).val().trim()) }]
      );
      partnerList.reload();
      }
      else {
      partnerList.reset();
      }
      }
      });

      $(partnerList.controls.btnSearch).click(function (e) {
      if ($(partnerList.controls.searchText).val().trim() != '') {
      $("div").removeData(partnerList.variables.srchKey);
      $("div").data("srchParams",
      [{ name: 'srchTxt', value: encodeURIComponent($(partnerList.controls.searchText).val().trim()) }]
      );
      partnerList.reload();
      }
      else {
      partnerList.reset();
      }
      });
      });


      I have written a variable partnerList and in controls add all its selectors. Is there any good way to write a script file, and any suggestions for me?







      javascript beginner jquery jquery-datatables






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 1 at 5:57









      Jamal

      30.2k11115226




      30.2k11115226










      asked Feb 1 at 5:23









      Lalji Dhameliya

      1747




      1747






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          $(partnerList.controls.searchText)
          $(partnerList.controls.btnSearch)


          These two elements look like they could be part of a form. Consider using a form. This way, you can 1) hook up a submit handler and only write the handler code once and 2) you pick up both the click of the submit button and the press of the Enter key. You'll have to use preventDefault to prevent the form from actually submitting and navigating away.



          $("div") is a bad way to select stuff. This affects all divs, regardless if you use it for your data table or not. Be more specific, use a class, don't blindly select all divs.



          $(partnerList.controls.searchText).val().trim() is being done twice. Unless that value changes between calls for some reason, it's best you cache it in a variable instead. Same goes for $('.datatable').



          $(function () {

          partnerList.initDatatable()

          const dataTables = $('.datatable')

          $(selectorToYourForm).on('submit', function (e) {
          e.preventDefault()
          const search = $(partnerList.controls.searchText).val().trim()

          if (search != '') {
          const name = 'srchTxt'
          const value = encodeURIComponent(search)

          dataTables.removeData(partnerList.variables.srchKey)
          dataTables.data('srchParams', [{ name, value }])

          partnerList.reload()
          } else {
          partnerList.reset()
          }
          })
          })





          share|improve this answer





















            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "196"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186493%2fdisplay-partner-information-javascript-file-using-jquery%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            $(partnerList.controls.searchText)
            $(partnerList.controls.btnSearch)


            These two elements look like they could be part of a form. Consider using a form. This way, you can 1) hook up a submit handler and only write the handler code once and 2) you pick up both the click of the submit button and the press of the Enter key. You'll have to use preventDefault to prevent the form from actually submitting and navigating away.



            $("div") is a bad way to select stuff. This affects all divs, regardless if you use it for your data table or not. Be more specific, use a class, don't blindly select all divs.



            $(partnerList.controls.searchText).val().trim() is being done twice. Unless that value changes between calls for some reason, it's best you cache it in a variable instead. Same goes for $('.datatable').



            $(function () {

            partnerList.initDatatable()

            const dataTables = $('.datatable')

            $(selectorToYourForm).on('submit', function (e) {
            e.preventDefault()
            const search = $(partnerList.controls.searchText).val().trim()

            if (search != '') {
            const name = 'srchTxt'
            const value = encodeURIComponent(search)

            dataTables.removeData(partnerList.variables.srchKey)
            dataTables.data('srchParams', [{ name, value }])

            partnerList.reload()
            } else {
            partnerList.reset()
            }
            })
            })





            share|improve this answer

























              up vote
              0
              down vote













              $(partnerList.controls.searchText)
              $(partnerList.controls.btnSearch)


              These two elements look like they could be part of a form. Consider using a form. This way, you can 1) hook up a submit handler and only write the handler code once and 2) you pick up both the click of the submit button and the press of the Enter key. You'll have to use preventDefault to prevent the form from actually submitting and navigating away.



              $("div") is a bad way to select stuff. This affects all divs, regardless if you use it for your data table or not. Be more specific, use a class, don't blindly select all divs.



              $(partnerList.controls.searchText).val().trim() is being done twice. Unless that value changes between calls for some reason, it's best you cache it in a variable instead. Same goes for $('.datatable').



              $(function () {

              partnerList.initDatatable()

              const dataTables = $('.datatable')

              $(selectorToYourForm).on('submit', function (e) {
              e.preventDefault()
              const search = $(partnerList.controls.searchText).val().trim()

              if (search != '') {
              const name = 'srchTxt'
              const value = encodeURIComponent(search)

              dataTables.removeData(partnerList.variables.srchKey)
              dataTables.data('srchParams', [{ name, value }])

              partnerList.reload()
              } else {
              partnerList.reset()
              }
              })
              })





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                $(partnerList.controls.searchText)
                $(partnerList.controls.btnSearch)


                These two elements look like they could be part of a form. Consider using a form. This way, you can 1) hook up a submit handler and only write the handler code once and 2) you pick up both the click of the submit button and the press of the Enter key. You'll have to use preventDefault to prevent the form from actually submitting and navigating away.



                $("div") is a bad way to select stuff. This affects all divs, regardless if you use it for your data table or not. Be more specific, use a class, don't blindly select all divs.



                $(partnerList.controls.searchText).val().trim() is being done twice. Unless that value changes between calls for some reason, it's best you cache it in a variable instead. Same goes for $('.datatable').



                $(function () {

                partnerList.initDatatable()

                const dataTables = $('.datatable')

                $(selectorToYourForm).on('submit', function (e) {
                e.preventDefault()
                const search = $(partnerList.controls.searchText).val().trim()

                if (search != '') {
                const name = 'srchTxt'
                const value = encodeURIComponent(search)

                dataTables.removeData(partnerList.variables.srchKey)
                dataTables.data('srchParams', [{ name, value }])

                partnerList.reload()
                } else {
                partnerList.reset()
                }
                })
                })





                share|improve this answer












                $(partnerList.controls.searchText)
                $(partnerList.controls.btnSearch)


                These two elements look like they could be part of a form. Consider using a form. This way, you can 1) hook up a submit handler and only write the handler code once and 2) you pick up both the click of the submit button and the press of the Enter key. You'll have to use preventDefault to prevent the form from actually submitting and navigating away.



                $("div") is a bad way to select stuff. This affects all divs, regardless if you use it for your data table or not. Be more specific, use a class, don't blindly select all divs.



                $(partnerList.controls.searchText).val().trim() is being done twice. Unless that value changes between calls for some reason, it's best you cache it in a variable instead. Same goes for $('.datatable').



                $(function () {

                partnerList.initDatatable()

                const dataTables = $('.datatable')

                $(selectorToYourForm).on('submit', function (e) {
                e.preventDefault()
                const search = $(partnerList.controls.searchText).val().trim()

                if (search != '') {
                const name = 'srchTxt'
                const value = encodeURIComponent(search)

                dataTables.removeData(partnerList.variables.srchKey)
                dataTables.data('srchParams', [{ name, value }])

                partnerList.reload()
                } else {
                partnerList.reset()
                }
                })
                })






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 1 at 17:58









                Joseph

                22.4k21835




                22.4k21835






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Code Review Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186493%2fdisplay-partner-information-javascript-file-using-jquery%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Сан-Квентин

                    8-я гвардейская общевойсковая армия

                    Алькесар