How to apply placeholder to Google Visualization c

2019-06-13 20:01发布

问题:

I have to apply placeholder to Google Visualization control wrapper string filter input.I tried with

var stringFilter = new google.visualization.ControlWrapper({
      'controlType': 'StringFilter',
      'containerId': 'search_container',
      'options': {
        'filterColumnLabel': 'Name',
        'matchType':'any',
        'ui': {'label': ''}
       }
});

google.visualization.events.addListener(stringFilter, 'ready', function(){
   $(".google-visualization-controls-stringfilter").prop('placeholder', "Search..");
});

but it does not work.

回答1:

You need to select the <input> that is inside the div with the class .google-visualization-controls-stringfilter:

google.visualization.events.addListener(stringFilter, 'ready', function () {
    $('.google-visualization-controls-stringfilter input').prop('placeholder', 'Search...');
});