Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIInteresting problem with clientcallbackInteresting problem with clientcallback
Previous
 
Next
New Post
9/23/2006 12:36 AM
 

I have created a skin object that uses the client API for clientcallbacks - while testing it came up with some weird results when this skin object is on the same page as the AJAX 'helloajax' module

apparently they interfere with each other -

If I load the blue or red control and then try to activte my skin object (client call back sets a flag in the database) I get an object is required message

After looking at it I had a function named the same - I have read about making JS scripts more object oriented which if you could give your script a sort of 'namespace' this sort of thing might not happen

Where can I dig up info on making sure my scripts have there own space and dont interfere with other scripts on the page?

TIA


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
9/25/2006 1:35 PM
 

The entire ClientAPI is coded this way.  For simplicity sake, the helloworld module is not.

Usually you can simply prefix your function names with something like

function codegalaxy_myfunction(param1)

{

alert(param1);

}

The way I handle it in dnn is to create a root object and use prototypes.

Edited

function codegalaxy()

{

}

codegalaxy.prototype =

{

 myfunction: function (param1)

  {

alert(param1);

}

{

 

Then call it with codegalaxy.myfunction('test');

 


 
New Post
9/25/2006 3:37 PM
 
Not being a JS guru like you  The whole prototypes thing is what I was looking for - thanks

Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
9/26/2006 9:39 PM
 

Okay got some of this I think

rewrote my functions like so

function Codegalaxy()

{

}

Codegalaxy.prototype =

{

successAddBookMark: function (result,ctx)

{

var sSubImage;

var sMessageBox;

switch(result)

{

case 'auth_neg' :

sRedirect = dnn.getVar('LoggedOutRedirect');

document.location.href = sRedirect ;

break;

case '1' :

sSubImage = dnn.getVar('RemoveImage');

sMessageBox = 'Bookmark Added';

dnn.dom.getById(ctx.id).src = result;

break;

default :

sSubImage = dnn.getVar('AddImage');

sMessageBox = 'Bookmark Removed';

}

dnn.dom.getById(ctx.id).src = sSubImage;

dnn.dom.getById(ctx.id).display = 'none';

dnn.dom.getById('yes_no').innerHTML = sMessageBox;

Codegalaxy_fadetext();

dnn.dom.getById(ctx.id).display = 'block';

}

}

but now I keep getting Codegalaxy is undefined - can you point me to some reference stuff on writing scripts with prototypes so I can try and figure out what the hell I am doing.


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
9/27/2006 9:33 AM
 

There is a ton of references out there for writing objects.  One thing I don't think I was clear on is that your definitions are the defining of a class with methods, you still need to instantiate the object.  Edit:  In fact looking back at the sample I gave you I was not clear, for I oversimplified it by using the same name.  Sorry about that.

var cg = new Codegalaxy();

cg.someMethod();

However, I also want to note that this is not the only solution to your problem.  You could simply name your methods

function Codegalaxy_someMethod()

Which would be a whole lot easier.


 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIInteresting problem with clientcallbackInteresting problem with clientcallback


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out