Access module function from ContentPane

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Access module function from ContentPane

Harry Devine
I have a custom module in an application I'm writing.  One of the areas I'm working on is clicking on a Tree item, which I can handle fine.  From there, I'm generating dynamic content in a ContentPane on the browser.  In this content on the ContentPane is a list of items that I'd like to have act like a hyperlink, and from there have the same content pane get that data.  So in my ContentPane content, I have <a href="#" onclick="webFunctions.showFolders(folderID)>Folder 1</a>. When I click on the link, I get "webFunctions is not defined".

How can I do this?  My module is included via require on my main file (index.php), and the content pane is inside of that file as <div data-dojo-type="dijit/layout/ContentPane">. The content pane is generated by calling request.post to get the data from a PHP file, and then set via registry.byId("myContentPane").set("content", data).

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Karl Tiedt
If you are generating the content in the browser, just have your generating code, connect the LI's using on()...

If the content is gernated via PHP on the backend you could attach an onLoad event to your CP and then connect the LI's once they have loaded via whatever set the contentPane initially.

-Karl Tiedt

On Fri, May 8, 2015 at 2:28 PM, Harry Devine <[hidden email]> wrote:
I have a custom module in an application I'm writing.  One of the areas I'm working on is clicking on a Tree item, which I can handle fine.  From there, I'm generating dynamic content in a ContentPane on the browser.  In this content on the ContentPane is a list of items that I'd like to have act like a hyperlink, and from there have the same content pane get that data.  So in my ContentPane content, I have <a href="#" onclick="webFunctions.showFolders(folderID)>Folder 1</a>. When I click on the link, I get "webFunctions is not defined".

How can I do this?  My module is included via require on my main file (index.php), and the content pane is inside of that file as <div data-dojo-type="dijit/layout/ContentPane">. The content pane is generated by calling request.post to get the data from a PHP file, and then set via registry.byId("myContentPane").set("content", data).

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Harry Devine
Thanks Karl.  I'll try that on Monday when I get back to work.  What do you mean by LI's though?  I'm drawing a blank.

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 4:21 PM, Karl Tiedt <[hidden email]> wrote:

If you are generating the content in the browser, just have your generating code, connect the LI's using on()...

If the content is gernated via PHP on the backend you could attach an onLoad event to your CP and then connect the LI's once they have loaded via whatever set the contentPane initially.

-Karl Tiedt

On Fri, May 8, 2015 at 2:28 PM, Harry Devine <[hidden email]> wrote:
I have a custom module in an application I'm writing.  One of the areas I'm working on is clicking on a Tree item, which I can handle fine.  From there, I'm generating dynamic content in a ContentPane on the browser.  In this content on the ContentPane is a list of items that I'd like to have act like a hyperlink, and from there have the same content pane get that data.  So in my ContentPane content, I have <a href="#" onclick="webFunctions.showFolders(folderID)>Folder 1</a>. When I click on the link, I get "webFunctions is not defined".

How can I do this?  My module is included via require on my main file (index.php), and the content pane is inside of that file as <div data-dojo-type="dijit/layout/ContentPane">. The content pane is generated by calling request.post to get the data from a PHP file, and then set via registry.byId("myContentPane").set("content", data).

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Karl Tiedt
I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt

On Fri, May 8, 2015 at 5:12 PM, Harry Devine <[hidden email]> wrote:
Thanks Karl.  I'll try that on Monday when I get back to work.  What do you mean by LI's though?  I'm drawing a blank.

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 4:21 PM, Karl Tiedt <[hidden email]> wrote:

If you are generating the content in the browser, just have your generating code, connect the LI's using on()...

If the content is gernated via PHP on the backend you could attach an onLoad event to your CP and then connect the LI's once they have loaded via whatever set the contentPane initially.

-Karl Tiedt

On Fri, May 8, 2015 at 2:28 PM, Harry Devine <[hidden email]> wrote:
I have a custom module in an application I'm writing.  One of the areas I'm working on is clicking on a Tree item, which I can handle fine.  From there, I'm generating dynamic content in a ContentPane on the browser.  In this content on the ContentPane is a list of items that I'd like to have act like a hyperlink, and from there have the same content pane get that data.  So in my ContentPane content, I have <a href="#" onclick="webFunctions.showFolders(folderID)>Folder 1</a>. When I click on the link, I get "webFunctions is not defined".

How can I do this?  My module is included via require on my main file (index.php), and the content pane is inside of that file as <div data-dojo-type="dijit/layout/ContentPane">. The content pane is generated by calling request.post to get the data from a PHP file, and then set via registry.byId("myContentPane").set("content", data).

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Harry Devine
Actially, I cycle through an array from my database and each item is added ad a table cell.  The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt

On Fri, May 8, 2015 at 5:12 PM, Harry Devine <[hidden email]> wrote:
Thanks Karl.  I'll try that on Monday when I get back to work.  What do you mean by LI's though?  I'm drawing a blank.

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 4:21 PM, Karl Tiedt <[hidden email]> wrote:

If you are generating the content in the browser, just have your generating code, connect the LI's using on()...

If the content is gernated via PHP on the backend you could attach an onLoad event to your CP and then connect the LI's once they have loaded via whatever set the contentPane initially.

-Karl Tiedt

On Fri, May 8, 2015 at 2:28 PM, Harry Devine <[hidden email]> wrote:
I have a custom module in an application I'm writing.  One of the areas I'm working on is clicking on a Tree item, which I can handle fine.  From there, I'm generating dynamic content in a ContentPane on the browser.  In this content on the ContentPane is a list of items that I'd like to have act like a hyperlink, and from there have the same content pane get that data.  So in my ContentPane content, I have <a href="#" onclick="webFunctions.showFolders(folderID)>Folder 1</a>. When I click on the link, I get "webFunctions is not defined".

How can I do this?  My module is included via require on my main file (index.php), and the content pane is inside of that file as <div data-dojo-type="dijit/layout/ContentPane">. The content pane is generated by calling request.post to get the data from a PHP file, and then set via registry.byId("myContentPane").set("content", data).

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Harry Devine
OK, its been a few days and I've been trying all sorts of things, but I'm REALLY stuck here.  So I thought I'd put some of my code snippets in this response in hopes that someone could see it and guide me in the right direction.

First, in my main page, I set up my dojoConfig as follows:

<script>
  var dojoConfig;
  (function() {
    dojoConfig = {
      async: 1,
      packages: [
        { name: "dgrid", location: "/dojoroot/dgrid" },
        { name: "xstyle", location: "/dojoroot/xstyle" },
        { name: "put-selector", location: "/dojoroot/put-selector"},
        { name: "myFunctions", location: "functions/js" }
      ]
    };
  }());
</script>

with the following requires:

<script type="text/javascript" src="/dojoroot/dojo/dojo.js"></script>
<script type="text/javascript">
  require(["dojo/parser",
              ...<others>...,
              "myFunctions/myFunctions"], function(parser, ..., myFunctions) {
     parser.parse();
   });
</script>

File js/myFunctions.js has a bunch of functions that I need throughout my app.  One of these is called showFolders, which is meant to be used later recursively:

showFolders: function(type,id) {
  request.post("folders.php", {
    handleAs: "text",
    method: "POST",
   data: {
     FolderType: type,
     FolderID: id
   },
   }).then (function(data) {
     registry.byId("pageContent").set("content", data);
   }, function(e) {
     console.log("error! ", e);
   });
}

In folders.php, I connect to a MySQL database using a PHP class I've written (the class handles the PHP/MySQL calls), and generate the page content dynamically based on what it returns.  What I'm trying to do is put the data into a table and when the user clicks on the Folder ID in the FolderID column, I want the action to be to call myFunctions.showFolders above with that Folder ID:

$content = "";
$content = $content . "<table>";
$content = $content . "<tr><td>Folder ID</td><td>Headline</td></tr>";
for ($i=0; $i < count($ids); $i++) {
  $content = $content . "<tr><td><span onclick=\"myFunctions.showFolders(' ', '" . $ids[$i]->FolderID . " ';\">" . $ids[$i]->FolderID . "</span></td><td>" . $ids[$i]->Headline . "</td></tr>";
}
$content . "</table>";
echo $content;             <---------------------- This is what is returned as data to request.post above

The content pane is generated properly, however, when I click on the FolderID, I get the error "Uncaught ReferenceError: myFunctions is not defined".  Since myFunction was included in the main require, and the content pane is within that main page, why is the myFunctions function data not available?  How can I achieve what I'm trying to do as described?

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Saturday, May 9, 2015 3:06:18 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Actially, I cycle through an array from my database and each item is added ad a table cell.  The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Karl Tiedt
Since AMD does not create globals, your ContentPane contents do not have access to myFunctions.... this is why I stated:

use ContentPane.onLoad callback
in that callback, use dojo.query or on() to setup events scoped to your myFunctions object as needed from your main code logic... problem solved.

-Karl Tiedt

On Wed, May 13, 2015 at 11:46 AM, Harry Devine <[hidden email]> wrote:
OK, its been a few days and I've been trying all sorts of things, but I'm REALLY stuck here.  So I thought I'd put some of my code snippets in this response in hopes that someone could see it and guide me in the right direction.

First, in my main page, I set up my dojoConfig as follows:

<script>
  var dojoConfig;
  (function() {
    dojoConfig = {
      async: 1,
      packages: [
        { name: "dgrid", location: "/dojoroot/dgrid" },
        { name: "xstyle", location: "/dojoroot/xstyle" },
        { name: "put-selector", location: "/dojoroot/put-selector"},
        { name: "myFunctions", location: "functions/js" }
      ]
    };
  }());
</script>

with the following requires:

<script type="text/javascript" src="/dojoroot/dojo/dojo.js"></script>
<script type="text/javascript">
  require(["dojo/parser",
              ...<others>...,
              "myFunctions/myFunctions"], function(parser, ..., myFunctions) {
     parser.parse();
   });
</script>

File js/myFunctions.js has a bunch of functions that I need throughout my app.  One of these is called showFolders, which is meant to be used later recursively:

showFolders: function(type,id) {
  request.post("folders.php", {
    handleAs: "text",
    method: "POST",
   data: {
     FolderType: type,
     FolderID: id
   },
   }).then (function(data) {
     registry.byId("pageContent").set("content", data);
   }, function(e) {
     console.log("error! ", e);
   });
}

In folders.php, I connect to a MySQL database using a PHP class I've written (the class handles the PHP/MySQL calls), and generate the page content dynamically based on what it returns.  What I'm trying to do is put the data into a table and when the user clicks on the Folder ID in the FolderID column, I want the action to be to call myFunctions.showFolders above with that Folder ID:

$content = "";
$content = $content . "<table>";
$content = $content . "<tr><td>Folder ID</td><td>Headline</td></tr>";
for ($i=0; $i < count($ids); $i++) {
  $content = $content . "<tr><td><span onclick=\"myFunctions.showFolders(' ', '" . $ids[$i]->FolderID . " ';\">" . $ids[$i]->FolderID . "</span></td><td>" . $ids[$i]->Headline . "</td></tr>";
}
$content . "</table>";
echo $content;             <---------------------- This is what is returned as data to request.post above

The content pane is generated properly, however, when I click on the FolderID, I get the error "Uncaught ReferenceError: myFunctions is not defined".  Since myFunction was included in the main require, and the content pane is within that main page, why is the myFunctions function data not available?  How can I achieve what I'm trying to do as described?

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Saturday, May 9, 2015 3:06:18 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Actially, I cycle through an array from my database and each item is added ad a table cell.  The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Harry Devine

I tried that and onLoad never fires.  I put a console.log in there and never saw it.  Any ideas on how to make that work?

Thanks,
Harry



On May 13, 2015 4:02:55 PM EDT, Karl Tiedt <[hidden email]> wrote:
Since AMD does not create globals, your ContentPane contents do not have access to myFunctions.... this is why I stated:

use ContentPane.onLoad callback
in that callback, use dojo.query or on() to setup events scoped to your myFunctions object as needed from your main code logic... problem solved.

-Karl Tiedt

On Wed, May 13, 2015 at 11:46 AM, Harry Devine <[hidden email]> wrote:
OK, its been a few days and I've been trying all sorts of things, but I'm REALLY stuck here.  So I thought I'd put some of my code snippets in this response in hopes that someone could see it and guide me in the right direction.

First, in my main page, I set up my dojoConfig as follows:

<script>
  var dojoConfig;
  (function() {
    dojoConfig = {
      async: 1,
      packages: [
        { name: "dgrid", location: "/dojoroot/dgrid" },
� �       { name: "xstyle", location: "/dojoroot/xstyle" },
        { name: "put-selector", location: "/dojoroot/put-selector"},
        { name: "myFunctions", location: "functions/js" }
      ]
    };
  }());
</script>

with the following requires:

<script type="text/javascript" src="/dojoroot/dojo/dojo.js"></script>
<script type="text/javascript">
  require(["dojo/parser",
              ...<others>...,
              "myFunctions/myFunctions"], function(parser, ..., myFunctions) {
     parser.parse();
   });
</script>

File js/myFunctions.js has a bunch of functions that I need throughout my app.  O ne of these is called showFolders, which is meant to be used later recursively:

showFolders: function(type,id) {
  request.post("folders.php", {
    handleAs: "text",
    method: "POST",
   data: {
     FolderType: type,
     FolderID: id
   },
   }).then (function(data) {
     registry.byId("pageContent").set("content", data);
   }, function(e) {
     console.log("error! ", e);
   });
}

In folders.php, I connect to a MySQL database using a PHP class I've written (the class handles the PHP/MySQL calls), and generate the page content dynamically based on what it returns.  What I'm trying to do is put the data into a table and when the user clicks on the Folder ID in the FolderID column, I want the action to be to call myFunctions.showFolders above with that Folder ID:

$content = "";
$content = $content . "<table>";
$content = $content . "<tr><td>Folder ID</td><td>Headline</td></tr>";
for ($i=0; $i < count($ids); $i++) {
  $content = $content . "<tr><td><span onclick=\"myFunctions.showFolders(' ', '" . $ids[$i]->FolderID . " ';\">" . $ids[$i]->FolderID . "</span></td><td>" . $ids[$i]->Headline . "</td></tr>";
}
$content . "</table>";
echo $content;             <---------------------- This is what is returned as data to request.post above

The content pane is generated properly, however, when I click on the FolderID, I get the error "Uncaugh t ReferenceError: myFunctions is not defined".  Since myFunction was included in the main require, and the content pane is within that main page, why is the myFunctions function data not available?  How can I achieve what I'm trying to do as described?

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Saturday, May 9, 2015 3:06:18 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Actially, I cycle through an array from my database and each item is added ad a table cell.   The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


-- 
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Sent from Kaiten Mail. Please excuse my brevity.
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Karl Tiedt

-Karl Tiedt

On Wed, May 13, 2015 at 1:35 PM, Harry Devine <[hidden email]> wrote:

I tried that and onLoad never fires.  I put a console.log in there and never saw it.  Any ideas on how to make that work?

Thanks,
Harry



On May 13, 2015 4:02:55 PM EDT, Karl Tiedt <[hidden email]> wrote:
Since AMD does not create globals, your ContentPane contents do not have access to myFunctions.... this is why I stated:

use ContentPane.onLoad callback
in that callback, use dojo.query or on() to setup events scoped to your myFunctions object as needed from your main code logic... problem solved.

-Karl Tiedt

On Wed, May 13, 2015 at 11:46 AM, Harry Devine <[hidden email]> wrote:
OK, its been a few days and I've been trying all sorts of things, but I'm REALLY stuck here.  So I thought I'd put some of my code snippets in this response in hopes that someone could see it and guide me in the right direction.

First, in my main page, I set up my dojoConfig as follows:

<script>
  var dojoConfig;
  (function() {
    dojoConfig = {
      async: 1,
      packages: [
        { name: "dgrid", location: "/dojoroot/dgrid" },
         { name: "xstyle", location: "/dojoroot/xstyle" },
        { name: "put-selector", location: "/dojoroot/put-selector"},
        { name: "myFunctions", location: "functions/js" }
      ]
    };
  }());
</script>

with the following requires:

<script type="text/javascript" src="/dojoroot/dojo/dojo.js"></script>
<script type="text/javascript">
  require(["dojo/parser",
              ...<others>...,
              "myFunctions/myFunctions"], function(parser, ..., myFunctions) {
     parser.parse();
   });
</script>

File js/myFunctions.js has a bunch of functions that I need throughout my app.  O ne of these is called showFolders, which is meant to be used later recursively:

showFolders: function(type,id) {
  request.post("folders.php", {
    handleAs: "text",
    method: "POST",
   data: {
     FolderType: type,
     FolderID: id
   },
   }).then (function(data) {
     registry.byId("pageContent").set("content", data);
   }, function(e) {
     console.log("error! ", e);
   });
}

In folders.php, I connect to a MySQL database using a PHP class I've written (the class handles the PHP/MySQL calls), and generate the page content dynamically based on what it returns.  What I'm trying to do is put the data into a table and when the user clicks on the Folder ID in the FolderID column, I want the action to be to call myFunctions.showFolders above with that Folder ID:

$content = "";
$content = $content . "<table>";
$content = $content . "<tr><td>Folder ID</td><td>Headline</td></tr>";
for ($i=0; $i < count($ids); $i++) {
  $content = $content . "<tr><td><span onclick=\"myFunctions.showFolders(' ', '" . $ids[$i]->FolderID . " ';\">" . $ids[$i]->FolderID . "</span></td><td>" . $ids[$i]->Headline . "</td></tr>";
}
$content . "</table>";
echo $content;             <---------------------- This is what is returned as data to request.post above

The content pane is generated properly, however, when I click on the FolderID, I get the error "Uncaugh t ReferenceError: myFunctions is not defined".  Since myFunction was included in the main require, and the content pane is within that main page, why is the myFunctions function data not available?  How can I achieve what I'm trying to do as described?

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Saturday, May 9, 2015 3:06:18 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Actially, I cycle through an array from my database and each item is added ad a table cell.   The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


-- 
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Sent from Kaiten Mail. Please excuse my brevity.

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Harry Devine
Thanks Karl!  I looked over your JSFiddle and took your advice, and I have something that is pretty much working using on.  However, I do have a question regarding your suggestion of using dojo.query.  My code uses dojo.query to look for any <span> tag that starts with "folderID-" (see function below).  The console.log statement in the on handler prints out the following:  clicked for  <span id="folderID-Testing">Testing</span>.  What I want to do is retrieve the id value, then I can call showFolders again (recursively) passing in that value as id.  How do I grab the id value for this?

showFolders: function(type,id) {
  var mod=this;
  request.post("folders.php", {
  handleAs: "text",
  method: "POST",
  data: {
    FolderType: type,
    FolderID: id
  },
  }).then (function(data){
    var content = registry.byId("webContent");
    if (content) {
      content.set("content", "");
    }
      var cp = new ContentPane({content: "test", onLoad: function() {
        query("span[ id^=\"folderID-\"]").forEach(function(node){
        on(node, "click", function() {
          console.log("clicked for ", node);
      });
    });
    }
  });
  cp.placeAt(registry.byId("webContent"));
  cp.set("content", data);
  cp.startup();

  }, function (e) {
    registry.byId("webContent").set("content", "Error retrieving Folder content");
  });
},


Thanks,
Harry


From: "Karl Tiedt" <[hidden email]>
To: [hidden email]
Sent: Wednesday, May 13, 2015 5:51:28 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane


-Karl Tiedt

On Wed, May 13, 2015 at 1:35 PM, Harry Devine <[hidden email]> wrote:

I tried that and onLoad never fires.  I put a console.log in there and never saw it.  Any ideas on how to make that work?

Thanks,
Harry



On May 13, 2015 4:02:55 PM EDT, Karl Tiedt <[hidden email]> wrote:
Since AMD does not create globals, your ContentPane contents do not have access to myFunctions.... this is why I stated:

use ContentPane.onLoad callback
in that callback, use dojo.query or on() to setup events scoped to your myFunctions object as needed from your main code logic... problem solved.

-Karl Tiedt

On Wed, May 13, 2015 at 11:46 AM, Harry Devine <[hidden email]> wrote:
OK, its been a few days and I've been trying all sorts of things, but I'm REALLY stuck here.  So I thought I'd put some of my code snippets in this response in hopes that someone could see it and guide me in the right direction.

First, in my main page, I set up my dojoConfig as follows:

<script>
  var dojoConfig;
  (function() {
    dojoConfig = {
      async: 1,
      packages: [
        { name: "dgrid", location: "/dojoroot/dgrid" },
         { name: "xstyle", location: "/dojoroot/xstyle" },
        { name: "put-selector", location: "/dojoroot/put-selector"},
        { name: "myFunctions", location: "functions/js" }
      ]
    };
  }());
</script>

with the following requires:

<script type="text/javascript" src="/dojoroot/dojo/dojo.js"></script>
<script type="text/javascript">
  require(["dojo/parser",
              ...<others>...,
              "myFunctions/myFunctions"], function(parser, ..., myFunctions) {
     parser.parse();
   });
</script>

File js/myFunctions.js has a bunch of functions that I need throughout my app.  O ne of these is called showFolders, which is meant to be used later recursively:

showFolders: function(type,id) {
  request.post("folders.php", {
    handleAs: "text",
    method: "POST",
   data: {
     FolderType: type,
     FolderID: id
   },
   }).then (function(data) {
     registry.byId("pageContent").set("content", data);
   }, function(e) {
     console.log("error! ", e);
   });
}

In folders.php, I connect to a MySQL database using a PHP class I've written (the class handles the PHP/MySQL calls), and generate the page content dynamically based on what it returns.  What I'm trying to do is put the data into a table and when the user clicks on the Folder ID in the FolderID column, I want the action to be to call myFunctions.showFolders above with that Folder ID:

$content = "";
$content = $content . "<table>";
$content = $content . "<tr><td>Folder ID</td><td>Headline</td></tr>";
for ($i=0; $i < count($ids); $i++) {
  $content = $content . "<tr><td><span onclick=\"myFunctions.showFolders(' ', '" . $ids[$i]->FolderID . " ';\">" . $ids[$i]->FolderID . "</span></td><td>" . $ids[$i]->Headline . "</td></tr>";
}
$content . "</table>";
echo $content;             <---------------------- This is what is returned as data to request.post above

The content pane is generated properly, however, when I click on the FolderID, I get the error "Uncaugh t ReferenceError: myFunctions is not defined".  Since myFunction was included in the main require, and the content pane is within that main page, why is the myFunctions function data not available?  How can I achieve what I'm trying to do as described?

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Saturday, May 9, 2015 3:06:18 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Actially, I cycle through an array from my database and each item is added ad a table cell.   The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



-- 
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Sent from Kaiten Mail. Please excuse my brevity.

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Access module function from ContentPane

Harry Devine
Figures!  Right after I send this, I find the answer.  I simply needed to pass node.id and got what I needed.

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Friday, May 15, 2015 9:02:54 AM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Thanks Karl!  I looked over your JSFiddle and took your advice, and I have something that is pretty much working using on.  However, I do have a question regarding your suggestion of using dojo.query.  My code uses dojo.query to look for any <span> tag that starts with "folderID-" (see function below).  The console.log statement in the on handler prints out the following:  clicked for  <span id="folderID-Testing">Testing</span>.  What I want to do is retrieve the id value, then I can call showFolders again (recursively) passing in that value as id.  How do I grab the id value for this?

showFolders: function(type,id) {
  var mod=this;
  request.post("folders.php", {
  handleAs: "text",
  method: "POST",
  data: {
    FolderType: type,
    FolderID: id
  },
  }).then (function(data){
    var content = registry.byId("webContent");
    if (content) {
      content.set("content", "");
    }
      var cp = new ContentPane({content: "test", onLoad: function() {
        query("span[ id^=\"folderID-\"]").forEach(function(node){
        on(node, "click", function() {
          console.log("clicked for ", node);
      });
    });
    }
  });
  cp.placeAt(registry.byId("webContent"));
  cp.set("content", data);
  cp.startup();

  }, function (e) {
    registry.byId("webContent").set("content", "Error retrieving Folder content");
  });
},


Thanks,
Harry


From: "Karl Tiedt" <[hidden email]>
To: [hidden email]
Sent: Wednesday, May 13, 2015 5:51:28 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane


-Karl Tiedt

On Wed, May 13, 2015 at 1:35 PM, Harry Devine <[hidden email]> wrote:

I tried that and onLoad never fires.  I put a console.log in there and never saw it.  Any ideas on how to make that work?

Thanks,
Harry



On May 13, 2015 4:02:55 PM EDT, Karl Tiedt <[hidden email]> wrote:
Since AMD does not create globals, your ContentPane contents do not have access to myFunctions.... this is why I stated:

use ContentPane.onLoad callback
in that callback, use dojo.query or on() to setup events scoped to your myFunctions object as needed from your main code logic... problem solved.

-Karl Tiedt

On Wed, May 13, 2015 at 11:46 AM, Harry Devine <[hidden email]> wrote:
OK, its been a few days and I've been trying all sorts of things, but I'm REALLY stuck here.  So I thought I'd put some of my code snippets in this response in hopes that someone could see it and guide me in the right direction.

First, in my main page, I set up my dojoConfig as follows:

<script>
  var dojoConfig;
  (function() {
    dojoConfig = {
      async: 1,
      packages: [
        { name: "dgrid", location: "/dojoroot/dgrid" },
         { name: "xstyle", location: "/dojoroot/xstyle" },
        { name: "put-selector", location: "/dojoroot/put-selector"},
        { name: "myFunctions", location: "functions/js" }
      ]
    };
  }());
</script>

with the following requires:

<script type="text/javascript" src="/dojoroot/dojo/dojo.js"></script>
<script type="text/javascript">
  require(["dojo/parser",
              ...<others>...,
              "myFunctions/myFunctions"], function(parser, ..., myFunctions) {
     parser.parse();
   });
</script>

File js/myFunctions.js has a bunch of functions that I need throughout my app.  O ne of these is called showFolders, which is meant to be used later recursively:

showFolders: function(type,id) {
  request.post("folders.php", {
    handleAs: "text",
    method: "POST",
   data: {
     FolderType: type,
     FolderID: id
   },
   }).then (function(data) {
     registry.byId("pageContent").set("content", data);
   }, function(e) {
     console.log("error! ", e);
   });
}

In folders.php, I connect to a MySQL database using a PHP class I've written (the class handles the PHP/MySQL calls), and generate the page content dynamically based on what it returns.  What I'm trying to do is put the data into a table and when the user clicks on the Folder ID in the FolderID column, I want the action to be to call myFunctions.showFolders above with that Folder ID:

$content = "";
$content = $content . "<table>";
$content = $content . "<tr><td>Folder ID</td><td>Headline</td></tr>";
for ($i=0; $i < count($ids); $i++) {
  $content = $content . "<tr><td><span onclick=\"myFunctions.showFolders(' ', '" . $ids[$i]->FolderID . " ';\">" . $ids[$i]->FolderID . "</span></td><td>" . $ids[$i]->Headline . "</td></tr>";
}
$content . "</table>";
echo $content;             <---------------------- This is what is returned as data to request.post above

The content pane is generated properly, however, when I click on the FolderID, I get the error "Uncaugh t ReferenceError: myFunctions is not defined".  Since myFunction was included in the main require, and the content pane is within that main page, why is the myFunctions function data not available?  How can I achieve what I'm trying to do as described?

Thanks,
Harry


From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Saturday, May 9, 2015 3:06:18 PM
Subject: Re: [Dojo-interest] Access module function from ContentPane

Actially, I cycle through an array from my database and each item is added ad a table cell.   The first cell needs to be clickable, and that click action should re-render the content pane with further data concerning the item clicked.  But the action is what I'm stuck on.  Do you have an example of using on to do this?

Thanks,
Harry

Sent from my iPad

On May 8, 2015, at 6:15 PM, Karl Tiedt <[hidden email]> wrote:

I assumed your "list of items" was in fact a list ie: <li>

-Karl Tiedt



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



-- 
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Sent from Kaiten Mail. Please excuse my brevity.

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest