Skip to content

Instantly share code, notes, and snippets.

@ClementDuez
Created December 19, 2012 11:09
Show Gist options
  • Save ClementDuez/4335986 to your computer and use it in GitHub Desktop.
Save ClementDuez/4335986 to your computer and use it in GitHub Desktop.
Add.html , coté vue Required : Jquery Pour l'ajax CF : ajaxUpload
<?php
$this->headTitle("Ajouter un article");
$formImage = $this->formImage;
$form = $this->form;
$form->setAttribute('action', $this->url('article', array('action' => 'add')));
echo $this->form()->openTag($form);
?>
<dl class="zend_form span8">
<dd><?php
echo $this->formInput($form->get('title'));
echo $this->formElementErrors($form->get('title'));
?></dd>
<dd><?php
echo $this->formTextArea($form->get('content'));
echo $this->formElementErrors($form->get('content'));
?></dd>
<dd>
Publier l'article :
<?php
echo $this->formInput($form->get('isPublished'));
echo $this->formElementErrors($form->get('isPublished'));
?></dd>
<dd><?php
echo $this->formInput($form->get('submit'));
echo $this->formElementErrors($form->get('submit'));
?></dd>
</dl>
<?php echo $this->form()->closeTag($form); ?>
<div class="span3">
<h4>Mes images</h4>
<div id="dropArea" class="span2 dragAndDrop" >LOL</div>
<?php
$formImage->setAttribute('action', $this->url('article', array('action' => 'addImage')));
echo $this->form()->openTag($formImage); ?>
<?php
echo $this->formInput($formImage->get('name'));
echo $this->formElementErrors($formImage->get('name'));
echo $this->formInput($formImage->get('file'));
echo $this->formElementErrors($formImage->get('file'));
echo $this->formInput($formImage->get('submit'));
echo $this->formElementErrors($formImage->get('submit'));
?>
<?php echo $this->form()->closeTag($formImage); ?>
</div>
<script type="text/javascript">
function ajaxUpdate(){
$.ajax({
type:"POST",
data:{content:$('#content').val()},
url:"/article/update",
success: function(retour){
alert('Contenu bien ennregistrer');
$("#content").empty().append(retour);
}
});
}
function lol(){
var content = $('#content').val();
console.log(content);
}
var x = setInterval("lol()", 5000);
clearInterval(x);
$('#content').on('focus', function(event){
x = setInterval("ajaxUpdate()", 5000);
console.log('focus');
// setInterval("lol()", 5000);
})
$('#content').on('blur', function(event){
console.log('blur');
clearInterval(x);
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment