Topic: Manually launch wave effect
Hello,
Is there a method to launch manually a wave effect with a script?
Thanks,
Jerome Ouvrard
Piotr Glejzer staff answered 6 years ago
Hi,
did you see that topic about that ?
https://stackoverflow.com/questions/36584226/materializecss-wave-ripple-effect-manually-trigger
AdamJakubowski staff pro premium priority answered 6 years ago
Hi ,
I do not know if I understand correctly but did you mean this: https://mdbootstrap.com/docs/jquery/javascript/waves-effect/ ? (launch via JavaScript)
Best Regards,
Adam
jouvrard pro answered 6 years ago
Sorry, my question wasn't clear.
In fact, I'd like to "activate" a wave effect on a div after for example 10s. So, I have my javascript counter but I'd like to know how can I launch this effect automatically (and not manually, sorry again…).
Thanks,
Jerome
AdamJakubowski staff pro premium priority answered 6 years ago
Hi,
try this
$(function(){ //paste your code here
});
paste it between your <script>
tag
jouvrard pro answered 6 years ago
Hum, sorry, but I can't see anything in your code. Only "$(function(){ //paste your code here});", and the problem for me is to have the code between the "{". :)
AdamJakubowski staff pro premium priority answered 6 years ago
Hi,
Try to paste this between your <script>
tag :
$(function(){ $("your element").addClass("waves-effect");});
in part "your element" paste class of the element responsible for wave effect in your code
Best,
Adam
jouvrard pro answered 6 years ago
Hello,
With this code I initialize the wave effect for an element, but what I would like is to launch the effect automatically, without clicking the button, is it possible?
I tried with a function like this:
$('#maNote').trigger("click");
The click is done (if I add an "alert" it works), but the wave effect isn't present (I have the waves-effect class in my element)
Thanks,
Jerome
TomekMakowski staff answered 6 years ago
Hi
You can always use $("#maNote").click()
and this will simulate a click.
regards
Tomek
jouvrard pro answered 6 years ago
Yes, it's the same effect than trigger('click'). :)
But even with this:
$( document ).ready(function() {
alert( "ready!" );
$(".maNote").click();
$(".maNote").click(function(){
alert("The paragraph was clicked.");
});
});
I have the "ready!" alert, and after the "The paragraph was clicked"... but no wave effect with a javascript click simulation. :(
I Don't know if there is a function like "$(".maNote").waves-effect()" for example?
jouvrard pro answered 6 years ago
It's now OK for me, I found the solution on http://fian.my.id/Waves/#api
For example, if you want to launch a waves effect after 3s after the document is opened:
$( document ).ready(function() {
setTimeout(function(){Waves.ripple('.myElement')}, 3000);
});
jouvrard pro answered 6 years ago
Hello,
It's Strange because I update my topic fex days ago with this solution (and it works! :)), but today I Don't see it, only your answer. :(
So, with:
$(document).ready(function() { Waves.ripple('#but_1'); });It works, thanks! :)
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.8.0
- Device: All
- Browser: All
- OS: All
- Provided sample code: No
- Provided link: No