Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

alpinejs examples stackoverflow

<div 
  x-data="{ selectedCountry: null, countries: [ 'Mexico', 'USA', 'Canada' ], storesByCountry: { 'USA': [ { 'store' : 'data' } ] } }"
>
  <select x-model="selectedCountry">
    <template x-for="country in countries" :key="country">
      <option :value="country" x-text="country"></option>
    </template>
  </select>
  Stores:
  <template x-for="store in storesByCountry[selected country] || []" :key="store.id">

  </template>
</div>
Comment

alpinejs examples stackoverflow

<div 
  x-data="{ selectedCountry: null, countries: [ 'Mexico', 'USA', 'Canada' ],  stores: [ { 'store' : 'data' } ] }"
  x-init="$watch('selectedCountry', (country) => { fetch('url?country=" + country).then(res=> res.json()).then((storeData) => { stores = storeData }) })"
>
  <select x-model="selectedCountry">
    <template x-for="country in countries" :key="country">
      <option :value="country" x-text="country"></option>
    </template>
  </select>
  Stores:
  <template x-for="store in stores" :key="store.id">

  </template>
</div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: underline unused code vscode 
Javascript :: jquery deparam 
Javascript :: react qurery jest test mock queryClientProvider 
Javascript :: React: readmore and read less 
Javascript :: js wrap function 
Javascript :: Jquery check if hover over child element 
Javascript :: es6 arrow function 
Javascript :: object assign js 
Javascript :: filtering in javascript 
Javascript :: javascript slider 
Javascript :: input as html in console 
Javascript :: js retry function if error 
Javascript :: Resize Image Using HTML Canvas in JavaScript 
Javascript :: javascript decrement 
Javascript :: make a if in jsx 
Javascript :: html to jsx 
Javascript :: remove string character in center javascript 
Javascript :: Which condition will print hello? var a=2; var b=3; if(a___?___b){console.log(“Hello”);} 
Javascript :: what is the use of useparams in react 
Javascript :: moment get difference between business dates 
Javascript :: crud in nodejs sequilize 
Javascript :: how to add elements into an array in javascript 
Javascript :: hide console log level in js 
Javascript :: dm discord.js 
Javascript :: jquery how to expand select 
Javascript :: using sequelize to read from a table 
Javascript :: javascript check if url ends with slash 
Javascript :: remove parent element javascript 
Javascript :: require("readline") noe js 
Javascript :: next auth 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =