Hide span with jquery is not working - javascript

I have a sharepoint webpart that shows some information from some lists, the lists are security trimmed, so if the user does not have permission to that list, it will show access denied. Which is fine.
I want to hide that part of the page.
I found how to solve it here:
http://www.timferro.com/wordpress/archives/227
This is the code I have:
<script src="/_layouts/Scripts/jquery1.8.1.min.js"></script><script language="javascript">
$("span:contains('Error')").hide();
$("div:contains('Access denied'):not(:has(div))").hide();</script>
And this is the screenshot that shows what I need to hide.
1
Better pic here
Update:
when I hide it, now sharepoint its showing me a blue line that I want to get rid off, but If I hide the blue line only, then a strange space will be between webparts, I think the best is to hide that TD that contains the rest of the things? How can I hide that?
Please see new screeenshot

looks like you forgot to put it inside the jQuery ready function:
$(function(){
$("span:contains('Error')").hide();
$("div:contains('Access denied'):not(:has(div))").hide();
});

Try below,
$(".UserGeneric span.ms-bold:contains('Error')").hide();
or If you want to hide the whole error then
$(".UserGeneric span.ms-bold:contains('Error')").parent().hide();

Related

Change content on click of button in jquery

So my scenario goes like this:
I have 3 kind on item to show in div. There are three buttons on top of div and when user click any of the button items corresponding to that items are shown.
Items comes from backend and I am getting all the items loaded on page load as I also need them some where else also within same context.
Currently I am following show hide approach for the same .What I want to know is can there be any other approach that can be better then this in terms of code optimisation. User can also edit /add./remove item?
Here is my fiddle
$(document).ready(function(){
console.log($('.toggleItems'));
$('.toggleItems').click(function(){
$('.containers').hide();
var identifier = $(this).data('identifier');
console.log(identifier);
$('#'+identifier).show();
});
})
First order by items then use accordion jquery

How to set an element to a default condition (hide ()) and when clicked (show())

Say I have a left-side chat bar with chat users. Each user has their image (much like Facebook's chat)and is clickable to open a chat box to start chatting away.
Here's my code:
$('.msg_wrap').hide();
$('.msg_box').hide();
$('.chat_user').click(function() {
$('.msg_wrap').show();
$('.msg_box').show();
}
I know this is wrong but what I want to do here is when the page loads for the first time, all the chatboxes to be hidden (hide ()). It is not until I click on a chat user (.chat_user) that a pop up/chat box appears (show()). How do I fix this code? Do I have to create a function?
A quick thought on a solution.
First. Set the elements ('.msg_wrap') and ('.msg_box') to hidden in your html and kill your first two lines of code. I am not sure what those elements specifically are, but, for example, if they were div tags it would look something like:
<div hidden class="msg_wrap">
Second. I am not sure if you are saying that the code currently isn't working on page load. It looks like you are missing a ) at the end and also you can update to the following so that it gets executed on page load.
$(function(){
$('.chat_user').click(function() {
$('.msg_wrap').show();
$('.msg_box').show();
});
});
This is jquery shorthand for $( document ).ready().
Also, if you want the msg_wrap and msg_box elements to toggle between being hidden and shown you can use the toggle() method instead of show().

jQuery toggle a box inside a box

Trying to build a guestbook with some jQuery features..
Now when im clicking at the "Post"box it appears a new box with the name "MenuBox" (This box is always hidden) i got the toggle part to work ALMOST.
The meaning of the MenuBox, is that it should show over the PostBox with a delete button so they can delete the post.
But now when i try to toggle it, it toggles all the boxes, is there a possible way of like making $("$(this) .MenuBox").click(
Anyone got any clue?
Sorry if the explanation is bad..
Provided that .MenuBox is a child of $(this):
$(this).find('.MenuBox').click(...);

Javascript: Tabs in an searchsystem?

Well I need a bit help here, i just dont get how i can manage to make that script dynamic.
I like to press one continent, and it opens the correct land - then from the land it should open the correct region -> And from there it should open the correct city.
Also it shouldn't try to open one, if this continent/land/region has no child-> no another tab.
Its my part of an search engine. The Php and HTML doesent need to be shown here, it works right.
I like to make an Tab system with that i could close every box, beside the first one.
That should be the box that contains the continents.
From there you select one point from that box, in example Europa. Then the box that contains the lands from Europa should be visible. Then you can again select the next step, here in example you select now in the second box Europa->Spain Then it should open the box with the content of spain and so on.
$(document).ready(function(){
$('#select_land_1').click(function(){
$('.box_land').hide();
$('.box_region').hide();
$('.box_city').hide();
$('#land_1').show();
$('#select_region_12').click(function(){
$('#region_12').show();
$('#select_city_34').click(function(){
$('#city_34').show();
});
$('#select_city_35').click(function(){
$('#city_35').show();
});
});
});
The Css looks like that :
http://img641.imageshack.us/img641/1479/bildnr1error.jpg
Thank you very much for your help :)
This:
$('.box_land'+'#land_1').show();
is weird and almost certainly not what you want. You didn't post any HTML, but perhaps you want just:
$('#land_1').show();
Same for the other one.

Input Box Option Drop Down

I'm looking at creating something like this:
http://konigi.com/interface/kontain-search
alt text http://s3.amazonaws.com/konigi/interface/kontain-search-2.png
I don't suppose anyone has any resources which could guide me? I know I'm not giving much information but I wouldn't know where to start looking.
Cheers!
EDIT Sorry, I meant just the drop down / input box, nothing else on that site.
EDIT AGAIN The drop down list is inside of the input box, hence why I was wondering.
It may be something similar to these examples but with only one main item. and manipulate with jquery each "li" and that action taken
example 1 |
example 2 |
example 3 |
example 4
edition answer: this is done with css.
is all contained in a div -> input + menu.
for the input is removed border styles and background color is the same as the container div.
Well, you put part of the search form in a hidden div and pop it up when the user clicks or hovers on some other element, either inside or outside the form. Use CSS as needed to position the div. Not really sure what problems you could possibly have with something like this.
Maybe you can be more specific and break this problem down in several more focused questions?
I did not drill into the site, but from a logical standpoint, perhaps the search box AND the dropdown are "inside" another element (div?) that forms the complex control...and just formated(CSS)/actions(jQuery) placed on those.
<div id="searchDiv">
<div id="searchText"></div>
<div id="searchDropdown"></div>
<div id="searchButton"><div>
</div>
Easy enough to set somthing like that up.
I think what's going on there isn't that the dropdown is inside an input box, but rather that the input box chrome is hidden and it's placed inside an input-looking div along with the dropdown.

Categories