0

I have a JQuery desktop like application that I have been working on. When a navigation link is clicked, it opens a new dialog. That part all works great. What I am having issues with is creating the icons in my toolbar for each dialog. The structure should look like this:

<Div id="minimize-footer>
<div id="category1>
<a href>Dialog Title  </>
<a href>Dialog Title  </>
</div>

<div id="category2>
<a href>Dialog Title  </>
<a href>Dialog Title  </>
</div>

and so on. The code should check if the category div exists and if it doesn't, create it and add the link. If it exists, I need to just add it to the already existing category div. I'm not sure why the code I'm using is not working. I have a fiddle created that I have been messing around with and would love a little direction in what I'm trying to do.

Thanks,

Fiddle

I have modified it so the buttons are being created, but it's not adding to the same category div, it's just adding a new one each time. Also instead of add the category to the div id, it just says object. This is what it's doing, I have updated the fiddle link to:

<div id="minimize-footer" class="dialog-700 ui-corner-all ui-button" title="Click to restore dialog">
<div id="[object" object]="">
<a>Title Dialog</a>
</div>
<div id="[object" object]="">
<a>Title Dialog</a>
</div>
<div id="[object" object]="">
<a>Title Dialog</a>
</div>
<div id="[object" object]="">
<a>Title Dialog</a>
</div>
</div>
3
  • Running your Fiddle with the Console open, I get: Uncaught ReferenceError: uiDialog is not defined Commented Mar 22, 2013 at 0:02
  • Thanks for noticing that. I have fixed that part. That's what I get for ripping out code and not paying to much attention to what it's doing. The code from the site is massive and works the way intended. All the variables pass in correctly, etc, I'm just having problems with creating the toolbar type part of it. Commented Mar 22, 2013 at 0:11
  • In the current version of the fiddle (10), $("#drug") matches nothing, and your if statement condition will always be false. How are you expecting the test the code with this fiddle? There is just a single button, and no way to tell it which category to add the link to. Commented Mar 22, 2013 at 0:58

1 Answer 1

1

Take a look at this Fiddle that I have edited. http://jsfiddle.net/VDrw7/

In your jsFiddle you had.

Category = $("drug");

which should be

Category = $("#drug");

because you are looking for an element with the ID of drug.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Alex, instead of creating the category div and appending the links to them. It's appending the attributes to toolbar itself.
I have modified it so the buttons are being created, but it's not adding to the same category div, it's just adding a new one each time. Also instead of add the category to the div id, it just says object. This is what it's doing, I have updated the fiddle link to:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.