JavaScript Keep VueJS snippet DRY

I have the following Vue HTML. I know this can be done with other modules but I prefer not to use unless it is needed. I have a select in a form the client fills out that has a select for the opening and closing times of each day. Obviously this can get redundant because I would be listing all the hours (every 15 min in my case) as options 2 times for each day and 7 times for all the days. It ends up being a couple hundred lines of code...for a hour select... Is there a better way to keep this DRY? I prefer to keep it in Vue land. Or JS in method etc...

<div class="col-xs-4">
  <select class="form-control" v-model="newPost.hours.sunday.opens">
    <option value="" selected>Opens:</option>
    <option value="12:00am">12:00am</option>
    <option value="12:15am">12:15am</option>
    <option value="12:30am">12:30am</option>
    <option value="12:45am">12:45am</option

...etc...etc x7
Answer:1

Add a property with all of the times to your component:

data() {
  return {
    times: ['12:00am', '12:15am', ...],
  }
}

Then use v-for in the template to generate the options:

<select class="form-control" v-model="newPost.hours.sunday.opens">
  <option value="" selected>Opens:</option>
  <option v-for="time in times" :value="time">{{ time }}</option>
</select>
Answer:2

I would like to get a knob animated right after my ajax call is done. I get a number, which the knob should progress to without a refresh. So what i want is: Ajax request is succesfull -> sends number ...

I would like to get a knob animated right after my ajax call is done. I get a number, which the knob should progress to without a refresh. So what i want is: Ajax request is succesfull -> sends number ...

I am trying to join an array of dates and values to an array of dates, without filtering out the extra dates. The LinqJS reference here is pretty confusing on how I would actually go about using the ...

I am trying to join an array of dates and values to an array of dates, without filtering out the extra dates. The LinqJS reference here is pretty confusing on how I would actually go about using the ...

  1. linq join syntax lambda
  2. linq join syntax c#
  3. linq join syntax multiple conditions
  4. linq join syntax method
  5. linq join syntax chain
  6. linq join query syntax
  7. linq join method syntax c#
  8. linq left join syntax
  9. linq join fluent syntax
  10. linq join function syntax
  11. linq join lambda syntax c#
  12. linq join expression syntax
  13. linq join method syntax example
  14. linq outer join syntax
  15. linq group join syntax
  16. linq join sql syntax
  17. linq inner join syntax
  18. linq join query syntax multiple conditions
  19. linq left join syntax c#
  20. linq join query syntax c#

I am facing some issues with escaping of back slash, below is the code snippet I have tried. Issues is how to assign a variable with escaped slash to another variable. var s = 'domain\\username'; var ...

I am facing some issues with escaping of back slash, below is the code snippet I have tried. Issues is how to assign a variable with escaped slash to another variable. var s = 'domain\\username'; var ...

I am trying to disable a textbox whenever a user checks the checkbox. I've done it with a single textbox and checkbox. I am now stuck what if user can add multiple textbox with checkbox? here is ...

I am trying to disable a textbox whenever a user checks the checkbox. I've done it with a single textbox and checkbox. I am now stuck what if user can add multiple textbox with checkbox? here is ...

  1. jquery disable textbox on checkbox click
  2. jquery disable textbox by id
  3. jquery disable textbox on dropdown change
  4. jquery disable textbox by name
  5. jquery disable textbox
  6. jquery disable textbox on page load
  7. jquery disable textbox not working
  8. jquery disable textbox asp.net
  9. jquery disable textbox when checkbox checked
  10. jquery disable textbox on click
  11. jquery textbox disable enable
  12. jquery remove textbox value
  13. jquery remove textbox
  14. jquery remove textbox readonly
  15. jquery remove textbox attribute
  16. jquery remove textbox border
  17. jquery textbox disabled attribute
  18. jquery textbox disabled false
  19. jquery disable input textbox
  20. jquery disable/enable textbox input when a checkbox is selected