Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to hide parent div if custom_field is empty

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #42683
    MadaHo
    Member

    Hi guys,

    I am not familiar with js or jquery but I need that to finish my “work”. I want to hide parent div bubble if value of, let say, custom_field (**CC_STAUS**) is empty.

    Below code is only a part of the rest:

    CC_STATUS

    and css

    .bubble {
    overflow:hidden;
    margin:5px 0 0 0;
    }
    .bubble .speach {
    background-color:#333333;
    color:#FFFFFF;
    padding:5px;
    margin:0;
    font-size: 12px;
    font-family: Segoe UI;
    text-transform: lowercase;
    }
    .bubble .arrow {
    margin:0 0 0 15px;
    width:0;
    height:0;
    border-left: 0px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #333333;
    border-top: 0;
    }

    To check the lenght of the **CC_STATUS** I have tried this code (which I simply adapted) but obviously it does not work. The bubble is always displaied no matter of it content.

    $(‘.bubble’).each(function() {
    if($(this).attr(‘CC_STATUS’) === ” || $(this).text() === ”) {
    $(this).parents(‘.bubble’).hide();
    }
    });

    See [jsfiddle](http://jsfiddle.net/9QayV/1/ “jsfiddle”)

    Thanks in advance for any (working) solution.

    #123771
    CrocoDillon
    Participant
    #124306
    MadaHo
    Member

    No, it must be the same as my code, CC_STATUS is a tag that trigger value from external server.
    Your code is showing one bubble with text and another one below without text.
    I need to find something that will check walue of CC_STATUS tag and then hide div.bubble if this value is empty.

    #124313
    chrisburton
    Participant

    Why wouldn’t you just use PHP for this?

    #124318
    MadaHo
    Member

    Hm… I’m creating template for instant messenger and **CC_STATUS** is used to get user description which I can display on contact list. So this tag, as many other like i.e. USER_NAME must be inserted in HTML code (not PHP) of the template.
    SO CC_STATUS is just constant element of the template. Is it possible that I could check with jquery that this tag has any value?

    #124362
    Derek Wood
    Participant

    nevermind

    #124399
    MadaHo
    Member

    IM (like Miranda or Trilian) is a program (so no live website) that is skinned almost the same way as HTML website. It is using IE engin to render themplate.
    To get some information about users we need to use some special tags – like CC_STATUS (for statuses), CC_NAME (for nicknames), CC_AVATAR (for avatars). There is a lot of other tags without template will not work. It looks probably the same as we creating website with PHP (in this case all information we take from database).
    Below is example of code displaing user table on contact list

    CC_USER_AVATAR

    CC_JID_PREFIX

    CC_STATUS

    including that part I am talkin about.

    I know that it is possible to write script that would check if CC_STATUS has any value – I mean if user in theyr messenger set any status (it can be just text, digit or url link or contain both).

    #124510
    MadaHo
    Member

    Yes, I have… And te result is:

    http://i47.tinypic.com/2ppkfm8.jpg

    I would like to get this (but without empty bubble if CC_STATUS has no value)

    http://i46.tinypic.com/2uyrggh.jpg

    And your code could look like this http://codepen.io/MadaHo/pen/GHAIa

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.