SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 43 of 43
  1. #26
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I've prepared a small test folder with a simple HTML page and all the Javascript that I use: test.zip

    To make the problem happen: click on the checkbox "Tipo" to hide the column with the same name. Click on it again to show it again. Up to this point everything works. Now click on it again to hide it and then click on "Espandi la tabella". You can see that the checkbox is being checked again but the column remains hidden.

    Thank you very much in advance for your help!

  2. #27
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Clicking on Espandi causes the Tipo section to show, but the checkbox becomes unticked. When you then check the Tipo checkbox, it tries to show the Tipo section but it's already shown, so you get the impression that nothing has happened. When you uncheck the Tipo checkbox it hide again.

    It seems that all of the checkboxes have been told to be the complete opposite of what they should be.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #28
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL I just realized that this is not the exact behavior that I get in my local testing environment XD Here, if I click on Espandi the checkbox remains ticked.

    Anyway, how do you suggest I solve this problem?

    Edit: I've created a test account on an actual running online version, so show you how the behavior of the script is different. Go to http://domus.danielpellarini.com and login using the credentials "test" "test".

    You can see here that clicking on Espandi ticks or unticks the checkboxes correctly, but still, if you go through the steps that I've written above to make the problem show, the column is not shown again if you click on Espandi after hiding it.

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    I suggest that you first get the checkboxes to corresponding with the visible columns.

    Once you do that, we can move on to other issues that may remain.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    I suggest that you first get the checkboxes to corresponding with the visible columns.

    Once you do that, we can move on to other issues that may remain.
    It works correctly in the online version.

  6. #31
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by D3V4 View Post
    It works correctly in the online version.
    So we ask, what is different in the script, between the two versions?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #32
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    So we ask, what is different in the script, between the two versions?
    As far as I remember, nothing.

  8. #33
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by D3V4 View Post
    As far as I remember, nothing.
    If there was nothing wrong then you wouldn't be facing a problem.

    Compare the expand.js scripts from both sources. You should find that there is a difference between them that is worth investigating.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #34
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are right, in one I trigger the click event, while in the other I edit the checked attribute.

  10. #35
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now that I've understood what the difference is, can you help me understand while it's not working correctly in either versions?

  11. #36
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by D3V4 View Post
    Now that I've understood what the difference is, can you help me understand while it's not working correctly in either versions?
    Before you were saying that it works correctly in the online version.

    Have you changed something there to make it not work?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #37
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, we are losing control here XD

    With "it works correctly in the online version" I mean that the checkboxes are ticked or unticked correctly (and not in the opposite way, like in the test page).

    The problem is still there though. Please do the following steps to make the problem appear:
    - go to the online version and login with the test credentials
    - untick the Tipo column to hide it (this works)
    - click on Espandi
    - the table is expanded, all the checkboxes become ticked, also the Tipo checkbox (correct), but the Tipo column is not shown again, even if now it's ticked (problem).

  13. #38
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Do it with the Indirizzo checkbox or the others after it, and you might understand why it is happening.

    Untick Indirizzo and click Espandi and Contrai, and you'll see that the column is being toggled blindly.

    You need the state of the checkbox to determine whether a column is shown or not. Currently that's not happening. Currently, the Espandi and Contrai is just blindly toggling the columns, without paying attention to whether they are already in their correct state.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #39
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Do it with the Indirizzo checkbox or the others after it, and you might understand why it is happening.
    I don't.

    You need the state of the checkbox to determine whether a column is shown or not. Currently that's not happening. Currently, the Espandi and Contrai is just blindly toggling the columns, without paying attention to whether they are already in their correct state.
    Shouldn't it work automatically, since the click event (and therefore the part of the code that hides or shows the columns) is triggered when the user clicks on Espandi?

    And should I add this check in stampa.js or in expand.js?

  15. #40
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Instead of this:

    $('#indirizzo').toggle();

    You need to use:
    $('#indirizzo').toggle( showOrHide )

    You can have the script decide whether to show or hide, depending on if the checkbox is already checked.

    If the checkbox is currently checked, you want showOrHide to be true so that the column gets shown.
    If it's not already checked, you want showOrHide to be false.

    Code javascript:
    var showOrHide = $(':checkbox[value="indirizzo"]:checked').length > 0;
    $('#indirizzo').toggle( showOrHide );

    Or if you want a one-liner:


    Code javascript:
    $('#indirizzo').toggle($(':checkbox[value="indirizzo"]:checked').length > 0);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  16. #41
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the test version of expand.js (the one in the downloadable folder) I've commented out the toggle() part, because I thought that it's redundant since I trigger the click event on the checkboxes.

    Is this correct?
    How should I modify this script to make it work?

  17. #42
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by D3V4 View Post
    How should I modify this script to make it work?
    I cannot help much further right now as it's approaching midnight, but with the info I've provided hopefully someone else can help you with that.

    My pumpkin approachs, avaunt!
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #43
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    I cannot help much further right now as it's approaching midnight, but with the info I've provided hopefully someone else can help you with that.

    My pumpkin approachs, avaunt!
    Thank you very much for your help, highly appreciated!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •