Wednesday 15 August 2012

javascript - JQuery get calling tag when dynamically loaded -


How can I locate the tag that calls a JQuery script when the tag gets dynamically loaded If so, what will be the last tag on the page?

I am using the Auto Advice library. I want to give some recommended items a different background color depending on their content, which I am currently adding JQuery inside the tag, which I'm adding to the string to present inside the selection div came back. After that, the item is suggested to get the div, I essentially need to get the parent () of the tag, and it has to change the CSS properties. How do I get this existing script tag though?

I am currently specifying an ID generated by generating each new tag JS variable - which works but is not very good! Can anybody anyway target me the tag directly with JQuery?

If this probably makes it clear, then this is my current selection renderer function.

  selectionRenderer: function (a) {var toRet = a.english; Var blueBgScript = "& lt; script id = ft" + freeTextFieldID + "& gt; $ ('# Feet' + Free TextField ID + ') .Parent (.css) (' Background ',' Blue '); & lt ; / Script> "If (a.id == a.english) {toRet + = blueBgScript; FreeTextFieldID ++; } To return; } << Code>   

Why do not you add some code after afterrender Event instead? Prefix var newMS = $ ('#') Add some tags to mark options that require a different background, then find parents and edit a square (or bg property) Magic (Suggestion) (): magicSuggest ({data: 'states.php', displayField: 'english', valueField: 'id', selection renderer: function (a) {var toRet = a.english; if (a .id == a English) toRet = "& lt; span class = 'freetext' & gt;" + toRet + "& lt; / span & gt;";; Return to;;},}); $ (NewMS) .on ('selectionchange', function (event, combo, selection) {var selDivs = $ (event.target._valueContainer [0] .ParentNode) .baby ('div'); // get all divs Selection ($.) (CELEDIV, Function (index, value) {// var span = $ (value) for each selected item ('. Freetext'); // If there is a duration of Client Fractacax (if Span.length == 1) $ (value). CSS ('background', 'blue'); // background rotation}};

No comments:

Post a Comment