Answer the question
In order to leave comments, you need to log in
How to pass the record ID to the handler?
I need to pass an ID value which is marked as $phone->primaryKey
<?php foreach ($model->phones as $phone) : ?>
<div class="row" id="phone_<?php echo $phone->primaryKey ?>">
<?php
echo $form->hiddenField($phone, 'Type_ID[' . $phone->primaryKey . ']', array('value' => $phone->Type_ID));
echo $form->hiddenField($phone, 'ID[' . $phone->primaryKey . ']', array('value' => $phone->ID));
?>
<?php echo $phone->type->Type_Phone; ?><br/>.
<?php echo $form->textField($phone, 'Number[' . $phone->primaryKey . ']', array('value' => $phone->Number, 'rows' => 1, 'cols' => 40)); ?>
<?php $this->widget('booster.widgets.TbButton', array(
'buttonType' => 'link',
'context' => 'default',
'icon' => 'glyphicon glyphicon-trash',
'url' => array('phone/delete', 'id' => $phone->primaryKey),
'htmlOptions' => array(
'class' => 'phone-remove',
'data-toggle' => "tooltip",
'title' => 'Удалить',
)
)); ?>
</div>
jQuery(document).ready(function () {
jQuery('.phone-remove').on('click', function () {
if (!confirm('Вы уверены, что хотите удалить данный элемент?')) return false;
var id=''; //тут надо как-то получить id
jQuery.ajax({
type: 'POST',
url: jQuery(this).attr('href'),
dataType:'json',
success: function (data) {
if (data.type==='success'){
$('#phone_' + id).detach();
}
}
});
return false;
});
});
Answer the question
In order to leave comments, you need to log in
In htmlOptions add
A in jsvar id = $('.phone-remove').data().id;
ruseller.com/lessons.php?rub=29&id=1030
dimation.ru/jquery/499-get-url-parameters-and-valu...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question