Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hi I'm trying to make a custom-styled checkbox in my angularjs application. Everytime a user checks or unchecks the checkbox, it sends a call to the server. However sometimes when I check or uncheck it sends null to the server via $HTPP service. What could be the problem?

BTW when I use normal checkboxes (unstyled) it works perfectly.

checkbox.html

        <!-- Custom checkbox portion of the html page -->
        <div class="criteria-two-col" ng-repeat="value in searchcriterias.gender">
             <div data-ng-click="newsearch('gender')">
             <input type='checkbox' class="styled-checkbox" id="gender{{value}}" value="    
         {{value}}" check-list='checked_gender'/>
             <label for="gender{{value}}"><span></span>{{value}}</label>
            </div>
         </div>

style.css

   /*Custom checkbox styling*/

 input[type="checkbox"].styled-checkbox {
   display: none;
     }

  input[type="checkbox"] + label {
  color:#000;
   font-weight:300;
  }

input[type="checkbox"] + label span {
display:inline-block;
width:19px;
height:19px;
margin:-1px 4px 0 0;
vertical-align:middle;
background:url(../../../images/check_radio_sheet.png) left top no-repeat;
cursor:pointer;
}

input[type="checkbox"]:checked + label span {
background:url(../../../images/check_radio_sheet.png) -19px top no-repeat;
}
share|improve this question
 
not sure why you posted css code, issue is more controller and/ or directive related. gender as string looks suspicious as argument and you have no ng-model so really need to show your controller code for ng-clcik. Better yet...create a demo in jsfiddle.net or plunker –  charlietfl Dec 11 at 2:05
 
the problem is the $http service sometimes posts a null value rather then a gender value such as male or female. I believe it may have something to do with the css side because when I use normal checkboxes it works fine. –  user1424508 Dec 11 at 2:09
 
possibly...but it's a long way from simple markup and css to seeing why events and ajax aren't doing what's expected...create a demo. Am surprised not using ng-change on checkbox instead of clcik on div. –  charlietfl Dec 11 at 2:16
 
ok i'll create a demo. thanks –  user1424508 Dec 11 at 3:35
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.