erotikat Posted October 18, 2012 Share Posted October 18, 2012 (edited) Bonjour, Je suis en train de convertir un module 1.4 en 1.5 et je me retrouve bloquée sur la partie ajax. controllers\admin\AdminMyModuleController.php contient les fonctions ci-dessous en plus de la fonction renderForm et renderList public function ajaxProcess() { if (Tools::isSubmit('customerFilter')) { $search_query = trim(Tools::getValue('q')); $customers = Db::getInstance()->executeS(' SELECT `id_customer`, `email`, CONCAT(`firstname`, \' \', `lastname`) as cname FROM `'._DB_PREFIX_.'customer` WHERE `deleted` = 0 AND is_guest = 0 AND active = 1 AND ( `id_customer` = '.(int)$search_query.' OR `email` LIKE "%'.pSQL($search_query).'%" OR `firstname` LIKE "%'.pSQL($search_query).'%" OR `lastname` LIKE "%'.pSQL($search_query).'%" ) ORDER BY `firstname`, `lastname` ASC LIMIT 50'); die(Tools::jsonEncode($customers)); } } public function setMedia() { parent::setMedia(); $this->addJqueryUI('ui.datepicker'); if ($this->tabAccess['edit'] == 1) { $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch')); } } public function renderForm() { ....... 'input' => array( array( 'type' => 'hidden', 'name' => 'id_customer', 'value' => 0 ), array( 'type' => 'text', 'label' => $this->l('Customer:'), 'name' => 'customerFilter', 'size' => 40, 'required' => true, 'class' => 'ac_input', 'autocomplete' => false ), ....... } views\templates\admin\MyModule_data\helpers\form qui contient {extends file="helpers/form/form.tpl"} er {block name="input"} {$smarty.block.parent} {/block} {block name="script"} $(document).ready(function() { function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } var currentToken = gup( 'token' ); $('#customerFilter') .autocomplete( 'ajax-tab.php', { minChars: 2, max: 50, width: 500, selectFirst: false, scroll: false, dataType: 'json', formatItem: function(data, i, max, value, term) { return value; }, parse: function(data) { var mytab = new Array(); for (var i = 0; i < data.length; i++) mytab[mytab.length] = { data: data[i], value: data[i].cname + ' (' + data[i].email + ')' }; return mytab; }, extraParams: { controller: 'AdminMyModule', token: currentToken, customerFilter: 1 } } ) .result(function(event, data, formatted) { $('#id_customer').val(data.id_customer); $('#customerFilter').val(data.cname + ' (' + data.email + ')'); }); }); {/block} Le problème, ajax me retourne une valeur vide Je voudrais reproduire le même fonctionnement que AdminCartRulesController mais dans un module sans passer par ajax.php mais ajax-tab.php. Merci de votre aide Edited October 22, 2012 by erotikat (see edit history) Link to comment Share on other sites More sharing options...
erotikat Posted November 13, 2012 Author Share Posted November 13, 2012 Une idée, une piste ? Merci Link to comment Share on other sites More sharing options...
belew Posted December 13, 2012 Share Posted December 13, 2012 Est ce que le template est bien utilisé ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now