Javascript Commands


Topic: Javascript Commands

adam.lloyd@health.wa.gov.au pro asked 7 years ago

I want to manipulate the provided MDB components via Javascript. Looking at some support answers, I find commands like: $(‘.mdb-select’).material_select(‘destroy’); Then update the data and initialize select again $(‘.mdb-select’).material_select();   So,  the question is: Where can I find all available Javascript commands in your documentation

Jakub Strebeyko staff answered 7 years ago

Hi there Adam, Thanks for reaching out! I'm not sure I fully understand - our documentation is the place with all available JavaScript "commands" (as long by this term you mean methods used to interact with the elements offered). There is no centralized list of all method names and their possible input one after another, if that's what you're after - each component is its own thing and the purpose of explaining them seemed better served with doing so separately. Let me know whether it answers your question. With Best Regards, Kuba
Hi Kuba, Thanks for the prompt reply. I have had a look at the documentation that is provided by your site, and is excellent. But I need to dynamically change the content of a dropdown via javascript.  Where in your documentation can I find: $(‘.mdb-select’).material_select(‘destroy’);  or  $(‘.mdb-select’).material_select(); which are two commands that I found in your support section of the site. Or Please provide example javascript that will allow me to dynamically :
  1. Clear all options
  2. Load new options
  3. Show new options
Thanks.  

Jakub Strebeyko staff answered 7 years ago

Hi there, Thanks for clarifying! Actually, both of the methods you mentioned are present in our docs (initialization - at the beginning of the article, destroy at its end). Anyway, you will need both and some extra to reach the goal, namely:
  • destroy the select ($(‘.mdb-select’).material_select(‘destroy’););
  • populate its options dynamically using jQuery and
  • reinitialize the select ($(‘.mdb-select’).material_select();)
Please refer here for a simple example. With Best Regards, Kuba
Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No