Jump to content

Costanza

Members
  • Content Count

    55
  • Joined

  • Last visited

Community Reputation

6 Neutral

About Costanza

  • Rank
    Newbie
  1. Well the code is really just like how I described. Some elements have their title set manually inline in the html, while others do not. The latter ones have an issue with TipTip. This is only something I experience with TipTip though, not with the browser tooltip. So in terms of the js code, you'd have to look at TipTip'scode, which I linked in my OP. It's too advanced for me to comprehend but I noticed that when assigning the title, he uses the attr() function. Does this function take the default value, not a computed one? Because that would explain it.
  2. Haha no, I dumped that awful idea of mine as soon as you guys showed me that you can create custom attributes and data values. Now I use data() for that stuff. The title attribute is a normal title, the name of the item (for example: "M4 upper receiver"). The line of code is this:loadoutPage += 'BARREL: ' + $('#' + barrelID).attr('title'); That's the whole line. It's not even within an if- or for- statement or anything that could alter any variables. My code for printing to a new page (loadoutPage) works fine for creating the new page, but where the title attributes should go it prints 'undefined'.
  3. That's exactly what I've done. I used alerts just before the line that returns undefined. The alerts display the value of suppressorID and tell me what type of object that $('#' + suppressorID)[0] is. Both return as expected: the id is the right id and the alert that tests the element type says it's a div which is true. I'm lost
  4. I think you're onto something there. What would be the solution? Because that might be what is happening because it is indeed calling this from a function (it is a user-initiated function when they click a button, not an onload or document.ready function). I should also mention that the element which I am retrieving the title of is set right in the html and loads from the start. I'm confused why this attr function would be trying to execute before I've executed the function it's contained in. I'm not getting an actual undefined error--the result of the attr() function is just returning undefined when I execute it.
  5. Yeah it all checks out. suppressorID returns the correct value (the id of the element I want) and $('#' + suppressorID)[0] says it's a div element, which is correct. If all that works, then how could the attr() function not possibly work? Weird.
  6. For some reason this code keeps returning 'undefined'. $('#' + suppressorID).attr('title') But I've tested the value of suppressorID and it returns the expected value, and the tooltip for the div works fine. What's weird is that this is such a basic function and nothing in my code alters the title attribute of these elements. I even used ctrl+F to search all my javascript for any other places which affect the title attribute in case I accidentally inserted something, but there was nothing. Where should I go from here in terms of testing to figure out the source of the problem? I don't know what else I can try. I see no reason why this shouldn't work.
  7. So after further testing I've learned this: --TipTip works on some elements of mine, but not all.--It works on ones that have a title explicitly set inline in my html.--It does NOT work in ones that have their title attribute set by javascript. For these ones, it has a small, empty tooltip. then if I rollover an element that works, and then rollover an element that doesn't work, it appears to work but it displays the title of the most recently rolled-over element that worked. I guess this functionality makes sense, but is there a way to make it work with non-default titles? If not, I can deal with it, but I'd like to know. As always, thank you!
  8. Oh man, sorry, I had just linked the css for the plugin incorrectly. However, now I am experiencing an issue with it where it simply doesn't display any content (it's supposed to display text: the title attribute of the element). The default browser tooltip works fine if I remove the plugin, but TipTip doesn't.
  9. I'm trying to use this beautiful plugin called TipTip. But on my page when I activate the script, my entire page suddenly gets shoved down about 700-800 pixels then jumps back up a second later, and no tooltip appears. The elements that I am trying to use this on are divs that are positioned absolutely, which each are contained inside their own individual container div that is positioned relatively (and is the same size). I'm betting that my positioning is what' s causing the problem but I don't know why because I'm not the guy who wrote the plugin and I can't understand a word of his code. He says that TipTip can be applied to any element, not just links so I thought this would work.
  10. Thanks! So the prop() method would be incorrect as well? I think I'll take your advice and just use data() and see how that goes.
  11. I have some if-statements that are like this: if ($('#' + handguardID).attr('hasSixRail')) I set the attribute hasSixRail to either true or false (no quotes) depending on the element but this if-statement always evaluate to true, even when the attribute is set to false. (alert window testing confirms so). So then I tried changing it to this: if ($('#' + handguardID).attr('hasSixRail') == true) But that always evaluates to false. I guess I could just change everything to strings if that would solve the problem (I did a test with changing one element's attribute into a string and it seemed to work fine) but I figured that boolean values would make more sense since the attribute can only ever be either true or false. Can attributes of elements only be strings or numbers, not booleans? What on earth is going on here? Thanks for your help!
  12. Thank you dsonesuk and Ingolme! How did I not know that? Well that makes my life a heck of a lot easier. I'm going to look into jQuery's documentation on adding attributes like you've shown there and see how this goes. Thanks again!
  13. I guess because css attributes are the only way i know how to do that lol. (besides global variables but I need properties that are attached to elements). Because what I actually need are custom attributes. (what I'm creating is not actually a page layout. It's a thing like Brownells.com's ar-15 creator, sort of) So I'm using properties that won't affect my page as a way to have 'custom' properties. I know, it's truly terrible and nuts, but I thought it was my only option. This seems like it's what I really need though: creating my own objects. That way I can create custom properties. I found this plugin:http://benalman.com/...Query.getObject Would this allow me to do something like this:globalVariable = jQuery.getObject('handguard').exampleProperty; ..where 'handguard' is a custom object I created myself?
  14. Ah ok, thank you! Now I'm screwed though because I need css attributes that won't affect the element their assigned to (weird, I know). So far, attributes like line-height, text-indent, etc have worked perfectly. but if border requires an actual visible border then I can't do what I need to do because I can't have a border (whereas text attributes don't require any text to actually be on the page). Is there away in javacript/html to add element/object specific variables, like in an object-oriented language? For example, if I could create attributes that don't already exist but later access them like I would access word-spacing or background-color for tons of individual elements. I just need about 8 non-global variables/attributes for each div (of which I will have a lot and all attributes will be unique values to that specific div). I'm checking out this page: http://www.w3schools.com/js/js_objects.asp Seems like what I need,except I'm kinda confused how to implement it for my purpose. I know I'm using the totally wrong language for this, but like i said, C++ and Java are way beyond my intellectual faculties
  15. I'm at the end of my rope here, this is driving me nuts. Why does this keep returning the wrong value? The variable endOfSixRail keeps getting assigned the wrong value because 'border-right-width' keeps returning as 0px even though it's explicitly assigned the value of 708px. (Note: I'm using jQuery here) endOfSixRail = $('#' + handguardID).css('border-right-width');alert(handguardID + ' ' + $('#' + handguardID).css('border-right-width') + ' endofsixrail: ' + endOfSixRail); handguardID checks out and returns the correct string so I have no idea how the rest doesn't also return the right values. This method of accessing divs and their css values (....$('#' + handguardID).css('border-right-width')...) is what I've done throughout the rest of my code and it has always worked fine. The variable declared at the beginning of my script (I also tried declaring it w/o assigned a value initially but same result): var endOfSideRail = '0px'; The CSS where border-right-width is assigned: #long_standard_triRail{background-image: url(../../OutlinePics_G36/handguards/long_standard_triRail.png);max-width: 645px; /*This is how far in from the left that the handguard's side rail begins*/max-height: 752px; /*This is how far in from the left that the handguard's side rail ends*/word-spacing: 214px;border-left-width: 569px; /*This is how far in from the left that the handguard's six rail begins*/border-right-width: 708px; /*This is how far in from the left that the handguard's six rail ends*/} Yes, I know this all looks insane, having a border of 708 pixels, but it's actually a non-existent border. I'm just using CSS rules as "trait" values for the purposes of my program. And yes, a smart person could make this type of application in Java or C++ but those languages are infinitely more difficult and time consuming to learn (been there) so I'm sticking with javascript.
×
×
  • Create New...