3. So, you'll see in the examples what you mean by that. First of all, let's identify where dynamic content can come from; it can come from two places. First of all, it can come from AJAX, so AJAX is a way of fetching content from the Server without refreshing the page.
8. This next line here assigns a click Function to anything with the Class flue slash dialog. So, I've set up a Div with this Class for an example. And then, when it's clicked this is what it does: it attaches some content after it using the jQuery after Function.
9. So, let's take a look at what that looks like real quick. On my Drupal Install, what I've done is created a block on the side that just has a Div in it with the glue slash dialog Class that we just looked at in the Code. So, when this is clicked it should add that content after it.
10. Indeed, it works; so I can keep clicking this and keep adding the new content. But, say I want to attach some Behavior to this content here that gets added dynamically. If I click on these, nothing happens right.
12. So, let's take a look at the Code again; what I'm going to do is go ahead and comment out this problematic way of doing things. We're going to look at the way that works with Drupal Behaviors. First of all, what we're going to do is define a Function inside of the Drupal dot Behaviors Object and we're going to name it according to our Module name; in this case, it's Glue, and we'll start with a capital letter.
13. If you wanted to, what you could do is just copy of Drupal Behavior's Function from another Module, and we'll take a look at a couple of Modules that implement this, in a bit. Just replace the name out with the Name of your Module with a capital. Then, everything inside here is basically what we want to put inside of the document dot ready Function that we use in the problematic way, just a second ago.
15. Otherwise, we'll continue the keep attaching Behaviors to it; say we click on it once, and the first time we click on it it creates one line of.
Learn how to work with the most important APIs in Drupal 6. This collection also covers import PHP concepts like working with arrays and functions, and explores how to use an IDE to speed up your development process. We also discuss:
- How to be aware of and fix security issues in your code
- How to create automated tests with SimpleTest and Selenium ID
- How to work with Ajax