Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 2.31 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how do i Find and then have a callback function
  2. //get all fields, some could be text, text area, checkbox, radio...
  3.  
  4. $(".my-field").each(function(i) {
  5. var wrapper = this;
  6.  
  7. //check if the text box has a vaule, this callback here is not working/ correct?
  8.  
  9. $(wrapper).find("input:text", function() {
  10.                 if ($(this).val() != "" || $(this).val().length > 0) {
  11.                     hidden++;
  12.                     $(wrapper).find(".field-content").hide();
  13.                     $(wrapper).addClass("hide");
  14.                 } else {
  15.                     visible = visible + 1;
  16.                 }
  17.             });
  18. });
  19.        
  20. <div data-field-type="Text" data-field-id="1" class="display-wrapper my-field">
  21.         <div class="field-header">
  22.             <span>name:
  23.                 xyz</span> | <span>
  24.                     text field</span>
  25.         </div>
  26.         <div class="field-content">
  27.             <div class="editor-label">
  28.                 <p class="clear">
  29.                     some description...</p>
  30.             </div>
  31.  
  32. <div class="editor-field">
  33.     <input type="text" value="iojhiojio" name="1" maxlength="100" id="field-1" class="field-bigtext">
  34. </div>
  35.             <br>
  36.         </div>
  37.         <div style="display: none;" class="field-error-wrapper">
  38.  
  39.         </div>
  40.     </div>
  41.        
  42. $(wrapper).find("input:text", function() {
  43. .. some code
  44. });
  45.        
  46. $(wrapper).find("input:text").each(function() {
  47.     if ($(this).val() != "" || $(this).val().length > 0) {
  48.         hidden++;
  49.         $(wrapper).find(".field-content").hide();
  50.         $(wrapper).addClass("hide");
  51.     }
  52.     else {
  53.         visible++;
  54.     }
  55. });
  56.        
  57. var inputElem = $(wrapper).find('input:text');
  58. if (inputElem.val() != "" || inputElem.val().length > 0) {
  59.     hidden++;
  60.     $(wrapper).find('.field-content').hide();
  61.     $(wrapper).addClass("hide");
  62. }
  63. else {
  64.     visible++;
  65. }
  66.        
  67. //get all fields, some could be text, text area, checkbox, radio...
  68. $(".my-field").each(function (i) {
  69.     var wrapper = this;
  70.     //check if the text box has a vaule, this callback here is not working/ correct?
  71.     $(wrapper).find("input:text").each(function () {
  72.         if($(this).val() != "" || $(this).val().length > 0) {
  73.             hidden++;
  74.             $(wrapper).find(".field-content").hide();
  75.             $(wrapper).addClass("hide");
  76.         } else {
  77.             visible = visible + 1;
  78.         }
  79.     });
  80. });