Skip to content

Instantly share code, notes, and snippets.

@leenasn
Last active September 20, 2019 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leenasn/e02014169f4bbfb1c08ccde097eddf46 to your computer and use it in GitHub Desktop.
Save leenasn/e02014169f4bbfb1c08ccde097eddf46 to your computer and use it in GitHub Desktop.
// controllers/search_controller.js
import { Controller } from "stimulus"
export default class extends Controller {
static targets = [ "query", "results" ]
search(){
var searchString = this.queryTarget.value
fetch(this.data.get("url")+"?query="+searchString)
.then(response => response.text())
.then(html => {
this.resultsTarget.innerHTML = html
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment