Closed xiaoliushifu closed 6 years ago
How's the form configured?
Oh,now I have figured it out。as I preveously think that exactly it is the jsFiles order。I change other way to insert my Js code like this:
<?php $this->beginBlock('damagecause');?>
$('#dialogForm').yiiActiveForm('add', {
id: 'stockoutdetail-damagecause',
name: 'damagecause',
container: '.field-stockoutdetail-bear_from',
input: '#stockoutdetail-damagecause',
error: '.help-block',
validate: function (attribute, value, messages, deferred, form) {
if ((function(attr,val) {
var radiovalue = $('input[type=radio][name=exchangeStatus]:checked').val();
return radiovalue != 2;
})(attribute, value))
{ yii.validation.required(value, messages, {'message':'some error message。'}); }
}
});
<?php $this->endBlock();?>
<!--**use View::registerJs**-->
<?= $this->registerJs($this->blocks['damagecause']);?>
View::registerJs will insert my customer js code into the view bottom defaultly ,like this:
Jquery(document).ready(function(){
// **my customer below here**。
});
</body>
I know that I borrow server's registerJS() method to insert my customer Js code。but I still don't know why I directly use this Jquery(document).ready(function(){}); would throw errors.
Something seems to be not initialized yet.
today I use add method in yiiActiveForm.js for a attribute, I do it as this below address tell,
but it always throw Error:
I wonder whether the jsFiles order is right. I debut it when it comes here in yii.activeForm.js below:
I put my code partially below:
I know the code above is right,because I modify the original code from Official into my app code. anyone meet this error? why that attributes is undifined ? I need your help!