1
urbanspacema
jquery admin side, debug problem

Hello fellow developer!
I'm working on a new module (quiet calm are just the beginning) but I need a hand.

In Admin Side,i'm doing a form that inserts a field in a table and I'm doing with jQuery, and now it works. Unfortunately, if active XOOPS debugging the ajax does not work anymore.

This is the code of the page format.php
include 'header.php';
if(isset(
$_GET['delete']))
{    
$sql 'DELETE FROM '.$xoopsDB->prefix('umus_format').' WHERE format_id = '.(int)$_GET['delete'];
    
$result $xoopsDB->queryF($sql);
    if(isset(
$_GET['ajax'])&&$_GET['ajax']==1)
        exit();
}
if (
$_REQUEST[fname] != ""){ 
    
$fname        htmlspecialchars(trim($_REQUEST['fname']));
    
$sql_insert "INSERT INTO ".$xoopsDB->prefix("umus_format")."(format_title) VALUES ('".$fname."')";
    
$result_insert $xoopsDB->queryF($sql_insert);
    
    
$fid $xoopsDB->getInsertId();
    echo 
$fid;
    exit();
    }

xoops_cp_header();
loadModuleAdminMenu(1"");
    
//includo js e css
include ('../include/library.php');

//per tutti i casi abilito il textsanitizer
$myts =& MyTextSanitizer::getInstance();
if (isset(
$_GET)) {
   foreach (
$_GET as $k => $v) {
      if(!isset($
$k))
          $
$k $v;
   }
}

if (isset(
$_POST)) {
   foreach (
$_POST as $k => $v) {
      if(!isset($
$k))
          $
$k $v;
   }
}
?>    
    
        
        Inserisci nuovo formato
        Formato:
            Formato inserito con successo.

            Aggiungi
        
    

    echo "
            "
._MI_UMUS_LISTFORMAT."
            "
._MI_UMUS_FORMAT_TITLE.""._MI_UMUS_ACTION."";
            
$sql 'SELECT * FROM '.$xoopsDB->prefix('umus_format').' ORDER BY format_title ';
            
$result $xoopsDB->queryF($sql);
    while(
$row mysql_fetch_array($result))
            {
    echo 
',$row['format_id'],'">
            '
.$row['format_title'].'
            .$row['format_id'].'" class="delete" >._MI_UMUS_DELETE.'" />
            
            '
;
            }
    echo 
"";
    
xoops_cp_footer();
?>


library.php
<link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="../css/umusic.css" />
<
script type="text/javascript" src="../library/jquery-1.3.2.min.js">script>
<
script type="text/javascript" src="../library/jquery.confirm.js">script>
<
script type="text/javascript" src="../library/jquery.mie.js">script>
<
script type="text/javascript" src="../library/jquery.color.js">script>


jquery.mie.js (my script)

//cancello un formato
$(document).ready(function() {
    $(
'a.delete').click(function(e) {
        
e.preventDefault();
        
//var parent = $(this).parent();
        
var parent = $(this).parent("td").parent("tr");
        {
        $.
ajax({
            
type'get',
            
url'format.php',
            
data'ajax=1&delete=' parent.attr('id').replace('record-',''),
            
success: function() {
                
parent.fadeOut(500,function() {
                
parent.remove();
                });
            }
        });
    }
    }).
confirm();
});

//stripe table
$(document).ready(function(){
    
    $(
'.stripeMe tr').mouseover(function(){
        $(
this).addClass("over");
    });
    
    $(
'.stripeMe tr').mouseout(function(){
        $(
this).removeClass("over");
    });
    
    $(
'.stripeMe tr:even').addClass('alt');

});

//creo un nuovo formato
    
$(document).ready(function(){
    $(
'form#submit').submit(function() {
    
    
// we want to store the values from the form input box, then send via ajax below
    
var fname  = $('#fname').attr('value');
    if (
fname != "") {
    
         $.
ajax({
            
type'post',
            
dataType'text',
            
url'format.php',
            
data'fname='fname,
            
success: function(fid){
                $(
'div.success').fadeIn(1000);
                $(
'div.success').fadeOut(3000);
                $(
'table#tablist').append("+fid+"' style='background-color:#ff6666; color:#ffffff;'>"+fname+"+fid+"' class='delete'>");                
                
            
                
                $(
'a.delete').click(function(e) {
                
e.preventDefault();
                
//var parent = $(this).parent();
                
var parent = $(this).parent("td").parent("tr");
                {
                $.
ajax({
                
type'get',
                
url'format.php',
                
data'ajax=1&delete=' parent.attr('id').replace('record-',''),
                
success: function() {
                
parent.fadeOut(500,function() {
                
parent.remove();
                });
            }
        });
    }
    }).
confirm();
    
}
});
}
    return 
false;
    });
});


2
Catzwolf
Re: jquery admin side, debug problem
  • 2009/3/24 1:30

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


It could be that XOOPS JS is conflicting with JQuery. If you can rename your JQuery functions etc. XOOPS uses $ in its js library.

3
trabis
Re: jquery admin side, debug problem
  • 2009/3/24 1:34

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You can't have any output before an ajax call or it will break it.
Just turn debug off for that page using:
error_reporting(0);
$xoopsLogger->activated false;

4
urbanspacema
Re: jquery admin side, debug problem

tnx catz and trabis.
Trabis This code must be placed in my file format.pho right?

5
urbanspacema
Re: jquery admin side, debug problem

Ok, work perfectly...
Unfortunately, so you can use the debugging with ajax ... Perhaps in future versions of XOOPS this thing can be corrected?

6
urbanspacema
Re: jquery admin side, debug problem

another question
in the file format.php i have many $variables that I would go to the javascript file jquery.mie.js for checking errors with cycles of IF.

I tried to assign a variable in the file format.php
$exist = "foo";

and called in javascript with this
var exist = ( '');

But it does not work...

at this time sending from file format.php to js file a variable $fid...

any idea?
tnx a lot
Urban

7
trabis
Re: jquery admin side, debug problem
  • 2009/3/24 13:57

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


I think you have to add a javascript function to set some vars.

Some think like:

var var1 = 0;
var var2 = 0;
function setVars(var1, var2){
this.var1 = var1;
this.var2 = var2;
}

and then use in php file something like

$var1 = 10;
$var2 = 20;
echo'

';

Just a guess :(

It would be easier if you build your javascript inside php and then echo it.

8
urbanspacema
Re: jquery admin side, debug problem

I try your version otherwise I put the js in the php file

Login

Who's Online

916 user(s) are online (81 user(s) are browsing Support Forums)


Members: 0


Guests: 916


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits