我正在尝试使用图像进行模态对话,您可以在其中选择多个图像.我需要从输入中获取值然后将其清空,但我无法清空输入.我试过.val('')和.val(null),但也为我工作.
这是完整的代码:
$("#hdselect").click(function(){
$(".modal").html("");
$.post('mediaservice.php',{hd:'ok',images:$("#hdimages").val()},function(data){
$(".modal").append(data);
});
$(".modal").dialog({
'modal':true,
'title':"Click the image to select",
'width':960,
'height':600,
'resizable':false,
'show': {effect: 'drop', direction: "up"},
'buttons': {"Ok": function() {
var hd=Array();
var hdval=$("#hdimages").val();
$("#hdimages").attr('value',' ');
$("input[name='hd[]']:checked").each(function(){
hd.push($(this).val());
});
if(hdval!=''){
hdval=hdval+","+hd;
}else{
hdval=hd;
}
$("#hdimages").val(hdval);
var images=$("#hdimages").val();
$.post('mediaservice.php',{getHd:images},function(data){
$("#imgthumbBase").append(data);
});
$(this).dialog("close");
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
这个想法是用户单击一个按钮,打开一个模式对话框,其中包含多个图像和复选框.此时我需要从输入中获取值,然后清除它.
我想用我自己的类来替换Laravels构建器类.我认为它会像问题一样简单,App::bind但似乎不起作用.我应该在哪里放置绑定,在Laravel中这样做的正确方法是什么?
这是我尝试过的:
我的建造者:
use Illuminate\Database\Eloquent\Builder as BaseBuilder;
class Builder extends BaseBuilder
{
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|static|null
*/
public function find($id, $columns = array('*'))
{
Event::fire('before.find', array($this));
$result = parent::find($id, $columns);
Event::fire('after.find', array($this));
return $result;
}
}
Run Code Online (Sandbox Code Playgroud)
接下来我尝试在bootstrap/start.php文件中注册绑定,如下所示:
$app->bind('Illuminate\\Database\\Eloquent\\Builder', 'MyNameSpace\\Database\\Eloquent\\Builder');
return $app;
Run Code Online (Sandbox Code Playgroud) 使用MultiCell()方法来实现所需的结构.在我在单元格中打印文本之前,它没问题.现在我需要放一个图像.我试图MultiCell()在TCPDF的Image()方法中使用但它打破了我的表的结构.这是一个什么解决方法?谢谢.
截断文件时,它会在开始时添加额外的零字节:
configFile, err := os.OpenFile("./version.json", os.O_RDWR, 0666)
defer configFile.Close()
check(err)
//some actions happen here
configFile.Truncate(0)
configFile.Write(js)
configFile.Sync()
Run Code Online (Sandbox Code Playgroud)
结果,文件具有我0在开头用一段字节写的内容.
如何在没有前导零的情况下截断并完全重写文件?
我试图在模型的beforeSave()方法中保存另一个模型的记录.我期望save()方法调用另一个模型beforeSave(),但它没有.它是一个bug还是我只是错过了什么?这是一些代码.
运营模式
public function beforeSave(){
if(parent::beforeSave()){
if($this->isNewRecord){
$this->creation_date=$this->modification_date=time();
$cur=Currencies::model()->find('LOWER(short)=?',array('usd'));
if($cur->id!=$this->currency_id){
$conv_cours=Currencies::model()->findByPk($this->currency_id);
$this->ammount_usd=round(($this->ammount*$conv_cours->buy)/$cur->sell,4);
}else{
$this->ammount_usd=$this->ammount;
}
}else{
$this->modification_date=time();
}
$opType=OperationType::model()->findByPk($this->operation_type);
$log=new ActionLogs;
$log->comment=Yii::app()->user->name.' ??????? '.$opType->name;
/*$log->logtime=time();
$log->user_id=Yii::app()->user->id;*/
$v=1;
$log->save ();
return true;
}else{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
和另一个模型之前保存()
public function beforeSave(){
if(parent::beforeSave()){
if($this->isNewRecord){
$this->logtime=time();
$this->user_id=Yii::app()->user->id;
}
return true;
}else{
return false;
}
Run Code Online (Sandbox Code Playgroud)
} 谢谢.
试图找到一种以编程方式创建具有某些排序规则的表的方法,但似乎无法找到如何正确执行此操作的方法。我正在使用 “doctrine/doctrine-migrations-bundle”:“2.1.*@dev”和Symfony 2.3,
我在 config.yml 中设置:
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: LATIN1
orm:
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
auto_mapping: true
doctrine_migrations:
dir_name: %kernel.root_dir%/../src/CF/EscritorioBundle/Migrations
namespace: MyNameSpace\Migrations
table_name: migrations
name: Application Migrations
Run Code Online (Sandbox Code Playgroud)
当我运行doctrine:database:create工具时,它使用 LATIN1 字符集和 latin1_swedish_ci 作为默认排序规则创建数据库。然后我运行我的迁移,所有的表都是utf8_general_ci
$schema->createTable()查看该函数,但找不到传递我需要的排序规则的方法。这里的正确解决方法是什么?
我正在为prestashop 1.5.3开发一个模块.我需要在模块安装期间创建自定义管理选项卡.我像这样安装
public function install()
{
if( (parent::install() == false)||(!$this->_createTab()) )
return false;
return true;
}
Run Code Online (Sandbox Code Playgroud)
而_createTab方法是:
private function _createTab()
{
$tab = new Tab();
$tab->id_parent = 7; // Modules tab
$tab->class_name='AdminWarranty';
$tab->module='fruitwarranty';
$tab->name[(int)(Configuration::get('PS_LANG_DEFAULT'))] = $this->l('Warranty');
$tab->active=1;
if(!$tab->save()) return false;
return true;
}
Run Code Online (Sandbox Code Playgroud)
没有任何反应..我做错了什么..以及在哪里找到好的prestashop开发人员参考.
我正在尝试清理一些数据,这些数据在字符串的开头有N个数字,在其余部分有一些数字.我只需要提取N个第一个数字.
这是一个示例字符串
1410{{data}} est un program56me de l?556?™
122 datadatadata5654df sdfs989
123datadatadata5654df sdfs989
Run Code Online (Sandbox Code Playgroud)
得到结果我需要
1410,122,123
Run Code Online (Sandbox Code Playgroud) 尝试按照官方文档中的自定义验证器作为服务示例.我在我的"services.yml"中将我的验证器定义为服务:
cf.validator.unique.in.system:
class: 'CF\AppBundle\Validator\Constraints\UniqueInSystemValidator'
arguments: ['@doctrine']
tags:
- { name: 'validator.constraint_validator', alias: 'cf.validator.unique.in.system' }
Run Code Online (Sandbox Code Playgroud)
我已经创建了必要的约束和验证器类:
约束
namespace CF\AppBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class UniqueInSystem extends Constraint
{
public $message = 'This value is already used.';
public function getTargets()
{
return self::CLASS_CONSTRAINT;
}
public function validatedBy()
{
return 'cf.validator.unique.in.system';
}
}
Run Code Online (Sandbox Code Playgroud)
验证器
namespace CF\AppBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Doctrine\Bundle\DoctrineBundle\Registry as Doctrine;
/**
* @Annotation
*/
class UniqueInSystemValidator extends ConstraintValidator
{
protected $em;
public function __construct(Doctrine $doctrine)
{
$this->em …Run Code Online (Sandbox Code Playgroud) php ×5
symfony ×2
doctrine ×1
doctrine-orm ×1
go ×1
html ×1
javascript ×1
jquery ×1
jquery-ui ×1
laravel ×1
laravel-4 ×1
prestashop ×1
regex ×1
symfony-2.3 ×1
tcpdf ×1
validation ×1
yii ×1