Create Checkboxes Dynamically #422

Closed
tneil opened this Issue Oct 26, 2012 · 8 comments

2 participants

@tneil
Open Source Projects member

Ability to create a checkbox dynamically after the DOM for a screen has been loaded.

  • Dynamic way to create/style a checkbox after screen is inserted into the DOM [Completed]
  • Update the existing checkbox sample page to just show the control working [Completed]
  • Add sample page to show how to manipulate control with JavaScript similar to the Dynamic Buttons page [Completed]
  • Remove the script id from the sample pages [Completed]
@tneil
Open Source Projects member

Design Example

Creating the checkbox dynamically should be created to be similar to that of the button control

// Create the element just like you would in a normal screen declaration
var checkbox = document.createElement('input');
checkbox.setAttribute('type','checkbox');
checkbox.setAttribute('value', 'foo');
checkbox.onclick = function() {
        alert(this.value);
    };

// Apply our styling
checkbox= bb.checkbox.style(checkbox);

// Insert it into the screen and update the scroller
document.getElementById('checkboxContainer').appendChild(checkbox);
bb.refresh();
@rrenna

The _bb10_dropdown object doesn't seem to contain a style() function for me. I do see a style function for Button and some others

@tneil
Open Source Projects member
@rrenna

My mistake, I meant that the checkbox object doesn't seem to contain a style() function

@tneil
Open Source Projects member

That is correct.. this is the requirement/feature request to add this functionality. The code sample is an example of what it should look like when completed.

@rrenna

Well then I'm an idiot. Thanks :)

@tneil
Open Source Projects member

LOL!!! I've updated the code example for better clarity :o)

@tneil tneil pushed a commit that referenced this issue Nov 9, 2012
Tim Neil updated samples for issue #422 68cf10a
@tneil tneil pushed a commit that referenced this issue Nov 9, 2012
Tim Neil sample update for issue #422 154d39f
@tneil tneil pushed a commit that referenced this issue Nov 9, 2012
Tim Neil sample updates for issue #422 971e896
@tneil tneil pushed a commit that referenced this issue Dec 6, 2012
Tim Neil updates for dynamic checkbox creation for issue #422 775ee79
@tneil
Open Source Projects member

Checkbox wiki page has now been updated

@tneil tneil closed this Dec 6, 2012
@arturolinares arturolinares added a commit to arturolinares/bbUI.js that referenced this issue Dec 14, 2012
Tim Neil updates for dynamic checkbox creation for issue #422 317b70d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment