I am playing around with a custom dashboard which has help bulletins to guide new users through the profile setup stage.
These bulletins change as the user completes certain task, but in the end I need to allow them to click a button to hide the "div" in which these bulletins are displayed.
Could someone help me comeup with the proper <button onclick> code to permanently hide this divide?
Thanks so much for all the help I have recieved so far!
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
- waya59@waya59
waya59 - 0 likes
- waya59@waya59
waya59 - 0 likes
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
- waya59@waya59
waya59 - 0 likes
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
- waya59@waya59
waya59 - 0 likes
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
You must log in to post replies.Off the top of my head, the first way I'd think to do it is...
//When user clicks certain button, do this
$user->hide_my_custom_div = "yes";
//When displaying the div...
if($user->hide_my_custom_div !== "yes") {
echo "<div>...</div>";
}
You could also use the private settings feature instead of metadata.
I thought about using the jquery hide function, but I'm not sure that I am calling the div function in the right way.
The div is named <div id="dashboard_info">
Inside of this function I wrote <button>Close</button> in html
Then inside of javascript I placed this code:
<script>
$("button").click(function () {
$("div.dashboard_info").hide();
});
</script>
The button shows up but the hide function doesn't work so I'm doing something wrong
Ok I got the jquery problem worked out, instead of "$("div.dashboard_info").hide();" I needed $('#dashboard_info').hide();
The only problem is that when the page is reloaded the div reappears. Is there a way to make this permanent?
i was thinking that there should be some way of setting a value to a variable when the div is hidden, then placing the code within an if statement. Just not sure about how to go about it.
If you want it to be permanent to a user, you need to write an action that sets a variable, then call it via ajax when the user clicks your button.
$.ajax() or $.post() are your friends here.
Hello again Evan,
Could you tell me where I can find some examples where $.ajax or $.post have been used like this? I'm really a newbe to this type of programming and kinda lost lol.
The jquery documentation is the best place to start to learn how to use $.post/ajax
http://api.jquery.com/jQuery.ajax/
Done spent a few hours going over that,,,,, some times I think I try to make stuff harder than it realy is.
I grew up on latterlogic from way back in 1982 or so I know a little about foxpro, C++ pertty good at html know some basic and bits and pieces of other languages...... then I found elgg lol PHP kicked my butt for a while and now I gotta figure out jquery I know I'll get it just wondering when lol.
It would be nice to see some real life examples of other peoples code,,,, don't know somehow that makes it easier
Examples are always easier. The jQuery docs usually have plenty of code examples. Here's one example specific to elgg, though:
<script>
$.post('//my.elgg.site/action/do/something', {
__elgg_ts: <?php echo $ts; ?>,
__elgg_token: "<?php echo $token; ?>"
}, function() { alert('yay'); });
</script>
this will call the action "do/something" with no arguments except the security tokens. Basically it is just like submitting a form to do/something but it does it in the background. Then, once the call returns (if it is a success) you will see 'yay' get alerted on your screen.