Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello all,
I am currently working on a problem I been having with some styling. I currently have checkbox list and it is in a line right now. I want to be able to have checkboxes in a row of 3 or 4.
I know that I could do this by making them in an unordered list. I currently grab all my data from a collection so I don’t have it hard coded as a unordered list or anything like that. I have a method call to get all of my data.
I want my method to make these items in an unordered list.
If you have some other suggestions that I could do to organize this data I am widely open to suggestions and ideas.
I know I am extremely close to getting this working on I am just having troubles with ending my unordered list.


JavaScript
//here is my method
    function initializeCheckBox(elementName, dataService, render, name) {
        if (render === null) render = function(item) { return(item.text); };
        var $element = $(elementName);        
        $.when(dataService()).then(function (data) {
            $element.append($unorderedList);
            for (var itemIndex in data) {
     var $input = $('<input type="checkbox" name ="'+name+'" value="' + data[itemIndex].value + '">' + render(data[itemIndex]) + '</input>');
                $input.data(data[itemIndex]);
		  $input.appendTo($element);
            }
        });
    }
//changing my method in an ordered list
    function initializeCheckBox(elementName, dataService, render, name) {
        if (render === null) render = function(item) { return(item.text); };
        var $element = $(elementName);        
        $.when(dataService()).then(function (data) {
            var $unorderedList = $('ul class="stylebox"');
            $element.append($unorderedList);
            console.log($unorderedList);
            for (var itemIndex in data) {
                var $input = $('<input type="checkbox" name ="'+name+'" value="' + data[itemIndex].value + '">' + render(data[itemIndex]) + '</input>');
                var $row = $('<li>'); 
                $input.data(data[itemIndex]);
				$input.appendTo($element);
            }
        });
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900