Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with checkboxes on cloned items #19

Closed
psolom opened this issue Feb 18, 2015 · 1 comment
Closed

Bug with checkboxes on cloned items #19

psolom opened this issue Feb 18, 2015 · 1 comment
Labels

Comments

@psolom
Copy link

psolom commented Feb 18, 2015

I have found a bug with checkboxes in current version on cloning items.
As you know for each checkbox yii creates hidden input with default {value="0"} and the checkbox itself has default {value="1"}. So we have:

<input type="hidden" name="Tickets[0][class]" value="0">
<input type="checkbox" id="tickets-0-class" class="selectbox" name="Tickets[0][class]" value="1">

But after cloning all cloned items have both input values as {value}, they lose their default value and after that data aren't sent correctly to controller:

<input type="hidden" name="Tickets[0][class]" value>
<input type="checkbox" id="tickets-0-class" class="selectbox" name="Tickets[0][class]" value>

I managed to fix it in 'afterClone' event in this way:

$('#dynamic-widget').on('afterClone' ,function(e, clonedItem) {
  $(this).find('input:hidden').val(0);
  $(this).find('nput:checkbox').val(1);
});

it works for me, but it is not the best solution I guess.
In fact it is not the widget bug but the jquery bug:
http://bugs.jquery.com/ticket/10550
There is described that bug has place in IE but I faced it in Chrome too.

@wbraganca wbraganca added the bug label Feb 18, 2015
@wbraganca
Copy link
Owner

Bug fixed by the new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants