how to empty search box on click event in wenzhixin bootstrap table without refresh page?
I want to empty search box. when I click anywhere on a page then without refresh page I want to get an only empty search box in a wenzhixin bootstrap table
<table id="view_table" data-toggle="table"
data-search="true"
data-page-list="[5, 10, 20]"
data-page-size="5"
data-pagination="true"
data-show-pagination-switch="true" >
<thead>
<tr class="table-heading">
<th data-field="image"><h4>Image</h4></th>
<th data-field="name"><h4>Name</h4></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button id="empty_search" class="btn btn-primary">Save</button>
<script>
$('#empty_search').on('click', function(){
$.(this.["data-search"]).empty();
});
</script>
javascript jquery css bootstrap-table
|
show 5 more comments
I want to empty search box. when I click anywhere on a page then without refresh page I want to get an only empty search box in a wenzhixin bootstrap table
<table id="view_table" data-toggle="table"
data-search="true"
data-page-list="[5, 10, 20]"
data-page-size="5"
data-pagination="true"
data-show-pagination-switch="true" >
<thead>
<tr class="table-heading">
<th data-field="image"><h4>Image</h4></th>
<th data-field="name"><h4>Name</h4></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button id="empty_search" class="btn btn-primary">Save</button>
<script>
$('#empty_search').on('click', function(){
$.(this.["data-search"]).empty();
});
</script>
javascript jquery css bootstrap-table
this.["data-search"]
makes no sense to begin with. Apart from thatthis
probably isn’t what you expect it to be in that context, the syntax is bogus as well - it is eitherfoo.bar
orfoo[bar]
- but not dot and square brackets.
– misorude
Nov 19 '18 at 11:27
try to use$( this ).data( "search", '' )
instead of$.(this.["data-search"]).empty()
– Stranger
Nov 19 '18 at 11:28
@Stranger, yes I tried but not work.
– vicky793
Nov 19 '18 at 11:54
@misorude, $('#empty_search').on('click', function(){ $("#view_table[data-search]").empty() }); is right?
– vicky793
Nov 19 '18 at 11:59
That would select thetable
element in your example (because it has that id, and has an attribute nameddata-search
) - but I doubt you actually want to “empty” the whole table(?). You are talking about a search field, but there is no such thing in the code you have shown above. If that field gets created dynamically by another script, then use your browser dev tools to inspect it and find out what id (or other characteristics suitable for selection, if necessary) it has. And to empty an input field, the right method would be setting the value to an empty string.
– misorude
Nov 19 '18 at 12:04
|
show 5 more comments
I want to empty search box. when I click anywhere on a page then without refresh page I want to get an only empty search box in a wenzhixin bootstrap table
<table id="view_table" data-toggle="table"
data-search="true"
data-page-list="[5, 10, 20]"
data-page-size="5"
data-pagination="true"
data-show-pagination-switch="true" >
<thead>
<tr class="table-heading">
<th data-field="image"><h4>Image</h4></th>
<th data-field="name"><h4>Name</h4></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button id="empty_search" class="btn btn-primary">Save</button>
<script>
$('#empty_search').on('click', function(){
$.(this.["data-search"]).empty();
});
</script>
javascript jquery css bootstrap-table
I want to empty search box. when I click anywhere on a page then without refresh page I want to get an only empty search box in a wenzhixin bootstrap table
<table id="view_table" data-toggle="table"
data-search="true"
data-page-list="[5, 10, 20]"
data-page-size="5"
data-pagination="true"
data-show-pagination-switch="true" >
<thead>
<tr class="table-heading">
<th data-field="image"><h4>Image</h4></th>
<th data-field="name"><h4>Name</h4></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button id="empty_search" class="btn btn-primary">Save</button>
<script>
$('#empty_search').on('click', function(){
$.(this.["data-search"]).empty();
});
</script>
javascript jquery css bootstrap-table
javascript jquery css bootstrap-table
edited Nov 19 '18 at 12:41
vicky793
asked Nov 19 '18 at 11:22
vicky793vicky793
327
327
this.["data-search"]
makes no sense to begin with. Apart from thatthis
probably isn’t what you expect it to be in that context, the syntax is bogus as well - it is eitherfoo.bar
orfoo[bar]
- but not dot and square brackets.
– misorude
Nov 19 '18 at 11:27
try to use$( this ).data( "search", '' )
instead of$.(this.["data-search"]).empty()
– Stranger
Nov 19 '18 at 11:28
@Stranger, yes I tried but not work.
– vicky793
Nov 19 '18 at 11:54
@misorude, $('#empty_search').on('click', function(){ $("#view_table[data-search]").empty() }); is right?
– vicky793
Nov 19 '18 at 11:59
That would select thetable
element in your example (because it has that id, and has an attribute nameddata-search
) - but I doubt you actually want to “empty” the whole table(?). You are talking about a search field, but there is no such thing in the code you have shown above. If that field gets created dynamically by another script, then use your browser dev tools to inspect it and find out what id (or other characteristics suitable for selection, if necessary) it has. And to empty an input field, the right method would be setting the value to an empty string.
– misorude
Nov 19 '18 at 12:04
|
show 5 more comments
this.["data-search"]
makes no sense to begin with. Apart from thatthis
probably isn’t what you expect it to be in that context, the syntax is bogus as well - it is eitherfoo.bar
orfoo[bar]
- but not dot and square brackets.
– misorude
Nov 19 '18 at 11:27
try to use$( this ).data( "search", '' )
instead of$.(this.["data-search"]).empty()
– Stranger
Nov 19 '18 at 11:28
@Stranger, yes I tried but not work.
– vicky793
Nov 19 '18 at 11:54
@misorude, $('#empty_search').on('click', function(){ $("#view_table[data-search]").empty() }); is right?
– vicky793
Nov 19 '18 at 11:59
That would select thetable
element in your example (because it has that id, and has an attribute nameddata-search
) - but I doubt you actually want to “empty” the whole table(?). You are talking about a search field, but there is no such thing in the code you have shown above. If that field gets created dynamically by another script, then use your browser dev tools to inspect it and find out what id (or other characteristics suitable for selection, if necessary) it has. And to empty an input field, the right method would be setting the value to an empty string.
– misorude
Nov 19 '18 at 12:04
this.["data-search"]
makes no sense to begin with. Apart from that this
probably isn’t what you expect it to be in that context, the syntax is bogus as well - it is either foo.bar
or foo[bar]
- but not dot and square brackets.– misorude
Nov 19 '18 at 11:27
this.["data-search"]
makes no sense to begin with. Apart from that this
probably isn’t what you expect it to be in that context, the syntax is bogus as well - it is either foo.bar
or foo[bar]
- but not dot and square brackets.– misorude
Nov 19 '18 at 11:27
try to use
$( this ).data( "search", '' )
instead of $.(this.["data-search"]).empty()
– Stranger
Nov 19 '18 at 11:28
try to use
$( this ).data( "search", '' )
instead of $.(this.["data-search"]).empty()
– Stranger
Nov 19 '18 at 11:28
@Stranger, yes I tried but not work.
– vicky793
Nov 19 '18 at 11:54
@Stranger, yes I tried but not work.
– vicky793
Nov 19 '18 at 11:54
@misorude, $('#empty_search').on('click', function(){ $("#view_table[data-search]").empty() }); is right?
– vicky793
Nov 19 '18 at 11:59
@misorude, $('#empty_search').on('click', function(){ $("#view_table[data-search]").empty() }); is right?
– vicky793
Nov 19 '18 at 11:59
That would select the
table
element in your example (because it has that id, and has an attribute named data-search
) - but I doubt you actually want to “empty” the whole table(?). You are talking about a search field, but there is no such thing in the code you have shown above. If that field gets created dynamically by another script, then use your browser dev tools to inspect it and find out what id (or other characteristics suitable for selection, if necessary) it has. And to empty an input field, the right method would be setting the value to an empty string.– misorude
Nov 19 '18 at 12:04
That would select the
table
element in your example (because it has that id, and has an attribute named data-search
) - but I doubt you actually want to “empty” the whole table(?). You are talking about a search field, but there is no such thing in the code you have shown above. If that field gets created dynamically by another script, then use your browser dev tools to inspect it and find out what id (or other characteristics suitable for selection, if necessary) it has. And to empty an input field, the right method would be setting the value to an empty string.– misorude
Nov 19 '18 at 12:04
|
show 5 more comments
2 Answers
2
active
oldest
votes
Here is an example: http://jsfiddle.net/9ynp8j6k/1/
You can empty the form field like this:
$('#clear').on("click",function() {
$('.bootstrap-table .form-control').val("");
});
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
add a comment |
When you click on the clear button so search box value reset and you search again new fresh data.
$('#clear').on("click",function() {
$('#bootstrap_table_ID').bootstrapTable("resetSearch","");
});
add a comment |
Your Answer
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: "1"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373565%2fhow-to-empty-search-box-on-click-event-in-wenzhixin-bootstrap-table-without-refr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is an example: http://jsfiddle.net/9ynp8j6k/1/
You can empty the form field like this:
$('#clear').on("click",function() {
$('.bootstrap-table .form-control').val("");
});
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
add a comment |
Here is an example: http://jsfiddle.net/9ynp8j6k/1/
You can empty the form field like this:
$('#clear').on("click",function() {
$('.bootstrap-table .form-control').val("");
});
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
add a comment |
Here is an example: http://jsfiddle.net/9ynp8j6k/1/
You can empty the form field like this:
$('#clear').on("click",function() {
$('.bootstrap-table .form-control').val("");
});
Here is an example: http://jsfiddle.net/9ynp8j6k/1/
You can empty the form field like this:
$('#clear').on("click",function() {
$('.bootstrap-table .form-control').val("");
});
answered Nov 19 '18 at 13:34
de-factode-facto
686
686
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
add a comment |
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
When I clicked anywhere in a table so table data did not reset and same data display or no record found a message to show.
– vicky793
Nov 29 '18 at 6:56
add a comment |
When you click on the clear button so search box value reset and you search again new fresh data.
$('#clear').on("click",function() {
$('#bootstrap_table_ID').bootstrapTable("resetSearch","");
});
add a comment |
When you click on the clear button so search box value reset and you search again new fresh data.
$('#clear').on("click",function() {
$('#bootstrap_table_ID').bootstrapTable("resetSearch","");
});
add a comment |
When you click on the clear button so search box value reset and you search again new fresh data.
$('#clear').on("click",function() {
$('#bootstrap_table_ID').bootstrapTable("resetSearch","");
});
When you click on the clear button so search box value reset and you search again new fresh data.
$('#clear').on("click",function() {
$('#bootstrap_table_ID').bootstrapTable("resetSearch","");
});
answered Nov 29 '18 at 8:22
vicky793vicky793
327
327
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373565%2fhow-to-empty-search-box-on-click-event-in-wenzhixin-bootstrap-table-without-refr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
this.["data-search"]
makes no sense to begin with. Apart from thatthis
probably isn’t what you expect it to be in that context, the syntax is bogus as well - it is eitherfoo.bar
orfoo[bar]
- but not dot and square brackets.– misorude
Nov 19 '18 at 11:27
try to use
$( this ).data( "search", '' )
instead of$.(this.["data-search"]).empty()
– Stranger
Nov 19 '18 at 11:28
@Stranger, yes I tried but not work.
– vicky793
Nov 19 '18 at 11:54
@misorude, $('#empty_search').on('click', function(){ $("#view_table[data-search]").empty() }); is right?
– vicky793
Nov 19 '18 at 11:59
That would select the
table
element in your example (because it has that id, and has an attribute nameddata-search
) - but I doubt you actually want to “empty” the whole table(?). You are talking about a search field, but there is no such thing in the code you have shown above. If that field gets created dynamically by another script, then use your browser dev tools to inspect it and find out what id (or other characteristics suitable for selection, if necessary) it has. And to empty an input field, the right method would be setting the value to an empty string.– misorude
Nov 19 '18 at 12:04