YUI3

YUI3

by Antonio Garmendía -
Number of replies: 6

Hi,

I used YUI3 and I don´t know why the page reload(refresh). I put the code below, thanks!!!

Cheers,

Tony

 

Javascript:

 

 NS.useful = function(id,table,useful,id_objeto)
    {
        //Valores
        var nom_table = Nom_Table(table);
        var temparray = '';
        var courseid = QueryString.id;
        
        temparray = 'tablename' + '=' + nom_table + '&' + 'id_tablename' + '=' + id + '&';
        temparray += 'courseid' + '=' + courseid + '&' + 'useful' + '=' + useful + '&' ;
        
        Y.io(M.cfg.wwwroot + '/course/format/socialmedia/actions/save_useful.php', {
            on: {
                    success:M.format_socialmedia.success_useful(id,table,useful,id_objeto),
                    failure:M.format_socialmedia.failure_useful                    
                }, context: M.format_socialmedia, method: 'post', data: temparray});        
    }

 

HTML

 

<span>

<a id="useful_1797" onclick="NS.useful(16,1,1,this.id);" href="#">Útil</a>
</span>
 
 

 

Average of ratings: -
In reply to Antonio Garmendía

Re: YUI3

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Tony,

Is there a JavaScript name space confusion?  I.e. should 'NS' be really 'M.format_socialmedia' in all cases?

Cheers,

Gareth

In reply to Gareth J Barnard

Re: YUI3

by Antonio Garmendía -

Hi Gareth,

I put this code too..

    M.format_socialmedia = M.format_socialmedia || {};
    NS = M.format_socialmedia = {};

The function work fine and return the values, but reload the page and I don´t know why. I hope you can help me. Thanks!!!

Cheers,

Tony

In reply to Antonio Garmendía

Re: YUI3

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Tony,

I still think that having both 'NS' and 'M.format_socialmedia' is confusing the issue and you should stick with 'M.format_socialmedia' only.  Try it and see what happens.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: YUI3

by Antonio Garmendía -

Dear Gareth,

I'll try only with 'M.fomat_socialmedia' and the page reload. I also did a function with an alert and happen the same thing. Another idea. Thanks!!!

Cheers,

Tony

In reply to Antonio Garmendía

Re: YUI3

by Matt Gibson -

Hi Antonio.

What were you expecting to happen and what happened instead? 

In reply to Matt Gibson

Re: YUI3

by Antonio Garmendía -

Dear Matt,

I expecting to save the information in the database and change a little the presentation. The thing is, that if we down the page and clic, the function work fine but in the end the page return to the begining and I want to stay. I hope that you understand me.

Cheers,

Tony