How do to make the simplest code for dynamic data?
Hello world!
I have a JSON file with more than 200 records.
I want that each record to be active button with unique actions.
The code is the following:
$.getJSON ("content.json",
{function (Data)}
for (var i = 0; i < 200; i ++) {}
var s = sym.getSymbol("base").createChildSymbol ("template", "CONT");
s.getSymbolElement ();
s.Element.attr ('id', 'symbol' + i);
s. $("imageholder") .css ({'background-image': "url ('" + data [i].) "}) (image_+_«_'_»)});
s. $("imageholder") .data ('myIndex', i);
s.$("imageHolder"). Data('title',Data[i].) (Name)
s.. Click$ ("imageholder") ("click", Function {}
If ($(this) .data ("myIndex") == 0) {}
WB = 10;
SYM.$("#symbol0"). Show();
SYM.$("#Symbol1"). Hide();
SYM.$("#Symbol2"). Hide();
SYM.$("#symbol3"). Hide();
sym.getComposition () .getStage ().getSymbol('placer').$("holder").css ({'background-image': "url (" + $(this).data('Large') + ")"});
sym.getComposition () .getStage ().getSymbol('placer').$("holdertxt").html ($(this) .data ('the kid'));
If (WB == 10) {}
sym.getSymbol("#symbol0").$("rect").animate ({opacity:1}, 700);
};
}
ElseIf ($(this) .data ("myIndex") == 1) {}
WB = 11;
SYM.$("#symbol0"). Hide();
SYM.$("#Symbol1"). Show();
sym.getComposition () .getStage ().getSymbol('placer').$("holder").css ({'background-image': "url (" + $(this).data('Large') + ")"});
sym.getComposition () .getStage ().getSymbol('placer').$("holdertxt").html ($(this) .data ('the kid'));
If (WB == 11) {}
sym.getSymbol("#symbol1").$("rect").animate ({opacity:1}, 700);
};
}
});
s. $("imageholder") .mouseout ("mouseout/mouseouthandler()", function (e) {}
If ($(this) .data ("myindex") == 0 & & WB! = 10) {}
sym.getSymbol("#symbol0").playReverse ("selectend");
}
ElseIf ($(this) .data ("myindex") == 1 & & WB! = 11) {}
sym.getSymbol("#symbol1").playReverse ("selectend");
}
}
});
s. $("imageholder") .mouseout ("mouseout/mouseouthandler()", function (e) {}
If ($(this) .data ("myindex") == 0 & & WB! = 10) {}
sym.getSymbol("#symbol0").play ("selectstart");
}
ElseIf ($(this) .data ("myindex") == 1 & & WB! = 11) {}
sym.getSymbol("#symbol1").play ("selectstart");
}
});
}
});
How is possible to place an each command or something else for not writing for each Index and for each function actions?
Now I'm writing for each function (passing of the mouse, click, mouseout/mouseouthandler()) the actions that each record in the JSON must do.
Can someone help me?
Based on your code above, I made the following assumptions:
- You have shown the code for two values of i (0 and 1) and want a similar code for the rest
- Two managers mouseout/mouseouthandler() in the code above is a typo, one of them is supposed to be a mouseover (according to the description at the bottom). In the solution, I will propose, I guess that one was supposed to be a manager of mouseover
- BM is a global variable and values range from 10, 11, 12... 10 + n - 1. Please check the code once though, I think that there is a logical problem with the closure, you create around WB in mouseout/mouseouthandler() handlers. I can't identify the intention if the proposed solution will be based on your code above.
Another bug in the code is in the way you join managers:
s.. Click$ ("imageholder") ("click", Function {}) must be changed to: s.$("imageholder"). on ("click", Function {})
and still other managers.
You can use the following to simplify your code:
$.getJSON("content.json", function (data) { for (var i = 0; i < data.length; i++) { var s = sym.getSymbol("base").createChildSymbol("template", "conts"); var e = s.getSymbolElement(); e.attr('id', 'symbol' + i); s.$("imageholder").css({ "background-image": "url('" + data[i].image + "')" }); s.$("imageholder").data('myIndex', i); s.$("imageholder").data('title', data[i].name); s.$("imageholder").on("click", function (e) { WB = 10 + i; sym.$("#symbol0").show(); sym.$("#symbol1").hide(); sym.$("#symbol2").hide(); sym.$("#symbol3").hide(); sym.getComposition().getStage().getSymbol('placer').$("holder").css({ "background-image": " url(" + $(this).data('Large') + ")" }); sym.getComposition().getStage().getSymbol('placer').$("holdertxt").html($(this).data('title')); sym.getSymbol("#symbol0").$("rect").animate({ opacity: 1 }, 700); }); s.$("imageholder").on("mouseover", function (e) { //Looks like a logical bug, please double check.. I don't know how you are controlling WB from outside if(WB != 10 + i) { sym.getSymbol("#symbol0").playReverse("selectend"); } }); s.$("imageholder").on("mouseout", function (e) { //Looks like a logical bug, please double check.. I don't know how you are controlling WB from outside if (WB != 10 + i) { sym.getSymbol("#symbol0").play("selectstart"); } }); } });
Another option would be to set up your event handlers in the symbol definition. The advantage is that all instances would automatically inherit the behavior. You just need to understand how to set the code. For example, in your case, you can attach the following click on Manager in the symbol itself imageholder element:
var i = sym.$("imageholder").data('myIndex'); //You will be setting the data on the instance while creating the instance. Rest of the code can use this as a param WB = 10 + i; //Assuming WB to be available, change the logic accordingly sym.$("#symbol0").show(); sym.$("#symbol1").hide(); sym.$("#symbol2").hide(); sym.$("#symbol3").hide(); sym.getComposition().getStage().getSymbol('placer').$("holder").css({ "background-image": " url(" + $(this).data('Large') + ")" }); sym.getComposition().getStage().getSymbol('placer').$("holdertxt").html($(this).data('title')); sym.getSymbol("#symbol0").$("rect").animate({ opacity: 1 }, 700);
The code does not work as it is, but I hope it helps you move forward and you are able to achieve what you wanted. Let us know if you encounter other problems.
DIA-
Tags: Edge Animate
Similar Questions
-
How can I get the color codes for the notebook
How can I get the color codes for the notebook?
Hello
What is the color codes for the notebook?
Perhaps you need a 3rd party utility like GetDiz - Free and others to be
found using BING or Google.GetDiz Notepad - free - replacement
http://www.Outertech.com/en/Notepad-replacementI hope this helps.
-
How can I find the URL codes for images stored in the Windows Photo Gallery?
How can I find the URL codes for images stored in the Windows Photo Gallery?
If you want the path to the current record
right click to the picture location of a photo...
and choose... Properties / General tab.
Location displays the path.If you have a photo saved on your hard drive
car that was downloaded on the net...
the original URL will appear not in
the file. -
How can I make the computer asks for a password before downloading a program?
How can I make the computer asks for a password before downloading a program?
Hello
You can configure the computer to request the password when you install any program using the User Account Control (UAC) on the computer. But you will not be able to make windows to ask password when you try to download and program.
You can check the link next on change control settings of user account for more information.
You can use any program of third-party download manager in which you can set a password when you download any file/program on the computer. You can use your favorite search engine to find any Download Manager for the browser software.
Warning: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.
-
HOW CAN I FIND THE MATCHING CODE FOR LEXMARK PRO 805
How can I find the pairing code for a printer Lexmark 805 purpose multi pro?
Contact Lexmark support.
-
I'm British, how do I make the default page for uk and USA not
Pages from Apple, always default USA icon and whenever I have change the British. How can I make the default country always default to the United Kingdom?
Are what page you referring?
-
How can I get the activation code for PC Defender?
I have a dell netbook. It has viruses on it. PC Defender is constantly on it saying that if I put in the activation code sent to my e-mail address, it will remove the virus. The code was never sent. I can't access it from my netbook, but I can check my email from my other laptop. How can I get the activation code so can clean my netbook?
PC Defender is a rogue security application. It is also a malware! You can remove it by following these instructions:
http://www.bleepingcomputer.com/virus-removal/remove-Windows-PC-Defender
Trader2100 -
I get a lot of my music from Soundcloud where individual songs are released by artists often with none of the albums.
So, when you add these songs on iTunes I the name of the album for each of them SoundCloud despite the fact that each of them have different names track/artists/works of art. When I select the option to indicate that the song is part of a compilation album, even if the individual work remains in each song and shows when I play the song, looking at my playlists, songs from my compilation album of SoundCloud will only show album art compilation rather than the individual works for each song. How can I my iTunes will show that each individual work?
You can't while retaining spacing as part of this same album. If you want each art individual to show then tracks them to a unique combination of the album title and album artist. If the tracks are underway on an older iPod then the tracks on the album must be unique.
TT2
-
How can I make the dark background for pages viewed in Acrobat Pro ms standard?
Just installed Acrobat DC Pro (Mac OS 10.10.2) and to change the light grey background for a dark gray standard page views but see no way to do it. Preferences are only the background color for the full screen display, display standard of the tools, menu, etc. The screen is too bright.
Hi Alline,
Update Acrobat DC published today (May 10, 2016) introduced a new darker theme. Please open Acrobat DC application and select help > check for updates to apply the latest update (2015.016.20039).
Then go to view > screen theme > dark grey and restart Acrobat.
More details here: What's new in Adobe Acrobat DC
If please try this out and let us know your comments.
Thank you
-ashu
-
While browsing with Mozilla, I would prefer not to have videos play unless I start the video. This applies to the advertising messages or any video.
Y at - it a preference to set it? If not, can you make one that does this?You can set plugins to "Ask to activate" on the page of "Firefox/tools > Modules > Plugins" to ask to confirm to allow the plugin to Firefox.
-
Unable to set the location of weather on the USAtoday home page to another location. Close/open Firefox and it failed in McClean, WILL.
then good for the weather, it is customize, in order for that to work, you must save the cookies for the site.
- Tools > Options > privacy
- If you're in private mode, or delete your cookies, it will not work.
-
How do I have the PUK CODE for ALCATEL OT - 55A
the phone is lock up
You must ask your service provider. Log on to their Web site - many have a button to click to request a PUK code
-
How can I get the serial code for this product
Hi, I can't find serail number to install my new photoshop elements it is not on the package, can anyone help thanks
Serial number FAQ recovery process. Point-of-sale activation products
Mylenium
-
How can I make the page of form for the Yahoo host?
How can I make the page of form for the Yahoo host?
I guess you want a contact form that sends data to your e-mail account.
- Find out if your hosting plan supports PHP code and the PHP mail() function.
If so, try this tutorial into 3 parts:
ALT-Web Design & Publishing: sensitive Contact form with 3.2 Bootstrap and PHP (part 1) - If your hosting plan does NOT support scripts, you will need to use a 3rd party like Wufoo.com service. They host the form processing scripts on their own servers for you.
Nancy O.
- Find out if your hosting plan supports PHP code and the PHP mail() function.
-
How to change the region code for DVD ROM on Acer Vista
See the title, I don't ' want to rewrite this, once again. Thank you
* original title - my computer won't let me change the region code for my disc drive. I have two different with region 1 and 2 DVDs. How can I change at will? Help! Good grief! My laptop is an Acer with windows vista.*
Hi Shakira R.
Please see the following article with useful information about your question:
http://www.Microsoft.com/windows/windowsmedia/KnowledgeCenter/mediaadvice/0072.mspx
I hope this helps!
Debra
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think
Maybe you are looking for
-
Why only a Yahoo Group displays the column group name?
I belong to several Yahoo groups and get individual emails from 3 of them. They all worked well until May 8, 2014, when the Freex news group began to display only "[email protected]" in the column. It's always like that. I can't be sure it's a Yah
-
Inactive links for quite awhile when opening pages
Recently I faced a problem when all the page links are inactive for some time (from 10 to 20 sec) when opening/refreshing of web pages.Loading of the page its content, it can be the object of a scroll, flash works, but links can be used only with a c
-
From time to time various web site displayed incorrectly - today, it's Facebook http://www.facebook.com/home.php?ref=hp but it another day it was my pages of the Bank.Generally, it corrects after the re - start the computer.Please advise how to stop
-
If the error code 43 makes you uninstall WLDD, replace with?
Accoding to what I could find, WLDD is a driver of hardware compatibility. For example, if you delete it, you create compatibility issues... To avoid these problems, you have to replace it with something that will make your compatible hardware... Wha
-
Need help how to extract files from laptop which has a damaged keyboard
I have an old laptop with a damaged keyboard that is running the same os as my new, Windows Vista and im trying to figure out how I can download files and media that I want to record as I am not keen to repair the old Toshiba satellite pro that the n