0

I have been trying to pass a variable to _F.search in this but no luck, can someone please help?

(function(window, $) {

 // 'use strict';
//setInterval(function () {alert("Hello")}, 3000);
  var StreamTable = function(container, opts, data) {
    return new _StreamTable(container, opts, data);
  };


  _F.search = function(text){
      alert("search " + text);
    var q = $.trim(text), count = 0;
     // alert(this.last_search_text);
    if (q == this.last_search_text) return;

    this.last_search_text = q;

    if(q.length == 0 ){
      this.render(0);
    }else{
      this.searchInData(q);
      this.render(0);
    }

    this.current_page = 0;
    this.renderPagination(this.pageCount(), this.current_page);
    this.execCallbacks('pagination');
  };
  }

I tried

onclick ="window.search(5)"

from a click button but still did not work.

1 Answer 1

2

The search function should be declared like this:

window.search = function(text){

This will attach the search function to the window object. This will allow you to attach it to the onclick event, like you have in your example:

onclick="window.search(5)"
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, but I do not want to re-define this code as it is already performing some other function for me.
_F is declared as var _F = _StreamTable.prototype;
Ok, it seems that you are only showing a small portion of the code here. It also seems like you are using a component I am unfamiliar with - i.e streamtable
Yes I only showed a small part because it is fairly long. It is from the Stream_table.js code.
It's from the library code itself? In that case _StreamTable.search(text) should just work... right?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.