Search Results

Search found 581 results on 24 pages for 'iterating'.

Page 4/24 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • jquery iterating through newly created elements

    - by jaeyun
    Hi All, I am trying to add new rows in my table, and save them into DB. First, I use .append() to append rows on the table: $("#tablename").append("<tr id='newRow'><td>newly added row</td></tr>"); The appending function works fine. My page displays the correct result. However, I am unable to select them with $("#newRow").each(function () { alert "it never reaches here!"; }); I am guessing it is because the elements are added after the DOM is loaded. Can anyone please tell me how I can iterate through all my newly added elements? Thank you.

    Read the article

  • Iterating through list of keys for associative array in JSON

    - by Simon_Weaver
    I have an associative array in JSON var dictionary = {"cats":[1,2,37,38,40,32,33,35,39,36], "dogs", [4,5,6,3,2]}; Can I get the keys from this? I tried in Visual studio putting a breakpoint but can't see any property that represents keys. Is it not possible? I'm fine creating a separate array if necessary, but was just hoping it wasnt : var keys = ["cats", "dogs"];

    Read the article

  • ClassCastException in iterating list returned by Query using Hibernate Query Language

    - by Tushar Paliwal
    I'm beginner in hibernate.I'm trying a simplest example using HQL but it generates exception at line 25 ClassCastException when i try to iterate list.When i try to cast the object returned by next() methode of iterator it generates the same problem.I could not identify the problem.Kindly give me solution of the problem. Employee.java package one; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class Employee { @Id private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Employee(Long id, String name) { super(); this.id = id; this.name = name; } public Employee() { } } Main2.java package one; import java.util.Iterator; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class Main2 { public static void main(String[] args) { SessionFactory sf=new Configuration().configure().buildSessionFactory(); Session s1=sf.openSession(); Query q=s1.createQuery("from Employee "); Transaction tx=s1.beginTransaction(); List l=q.list(); Iterator itr=l.iterator(); while(itr.hasNext()) { Object obj[]=(Object[])itr.next();//Line 25 for(Object temp:obj) { System.out.println(temp); } } tx.commit(); s1.close(); sf.close(); } }

    Read the article

  • PHP/XPath: Iterating through ancestor nodes in XML using SimpleXML

    - by StackOverflowNewbie
    I need to loop through the Ancestors nodes in order to get corresponding BrowseNodeId and Name values. How do I do this using XPath? I'm trying something like the the following, but it's not working: //BrowseNode[1]//Ancestors[1]/BrowseNode/BrowseNodeId/text() //BrowseNode[1]//Ancestors[1]/BrowseNode/Name/text() I think the //Ancestors part of the XPath is actually searching the entire XML tree. What I need to do is visit each node to get the needed values. How do I do this? In the example below, I want: Europe - History - Subjects - Books. Example XML: <BrowseNode> <BrowseNodeId>4952</BrowseNodeId> <Name>France</Name> <Ancestors> <BrowseNode> <BrowseNodeId>4935</BrowseNodeId> <Name>Europe</Name> <Ancestors> <BrowseNode> <BrowseNodeId>9</BrowseNodeId> <Name>History</Name> <Ancestors> <BrowseNode> <BrowseNodeId>1000</BrowseNodeId> <Name>Subjects</Name> <IsCategoryRoot>1</IsCategoryRoot> <Ancestors> <BrowseNode> <BrowseNodeId>283155</BrowseNodeId> <Name>Books</Name> </BrowseNode> </Ancestors> </BrowseNode> </Ancestors> </BrowseNode> </Ancestors> </BrowseNode> </Ancestors> </BrowseNode>

    Read the article

  • Iterating dictionary indexes in django templates

    - by unclaimedbaggage
    Hi folks...I have a dictionary with embedded objects, which looks something like this: notes = { 2009: [<Note: Test note>, <Note: Another test note>], 2010: [<Note: Third test note>, <Note: Fourth test note>], } I'm trying to access each of the note objects inside a django template, and having a helluva time navigating to them. In short, I'm not sure how to extract by index in django templating. Current template code is: <h3>Notes</h3> {% for year in notes %} {{ year }} # Works fine {% for note in notes.year %} {{ note }} # Returns blank {% endfor %} {% endfor %} If I replace {% for note in notes.year %} with {% for note in notes.2010 %} things work fine, but I need that '2010' to be dynamic. Any suggestions much appreciated.

    Read the article

  • Is the a pattern for iterating over lists held by a class (dynamicly typed OO languages)

    - by Roman A. Taycher
    If I have a class that holds one or several lists is it better to allow other classes to fetch those lists(with a getter) or to implement a doXList/eachXList type method for that list that take a function and call that function on each element of the list contained by that object. I wrote a program that did a ton of this and I hated passing around all these lists sometimes with method in class a calling method in class B to return lists contained in class C, B contains a C or multiple C's (note question is about dynamically typed OO languages languages like ruby or smalltalk) ex. (that came up in my program) on a Person class containing scheduling preferences and a scheduler class needing to access them.

    Read the article

  • Iterating through same form elements

    - by Hulk
    If a form has same tag repeatedly. How to get its value in javascript. <script> function validate() { //get all values of elmone } </script> <form> <input type="text" size="15" value="Hello World" name="elmOne"> <input type="text" size="15" value="next Hello World" name="elmOne"> <input type="button" onclick="javascript:validate()" value="validate"> </form> Thanks..

    Read the article

  • Java - problems iterating through an ArrayList

    - by cc0
    Ok so I have an ArrayList (arrBok), which is full of book objects (the code is in Norwegian, so pay no attention to that please). I want to make a public method which iterates through all the objects in the arraylist. When I execute the code, it just seems to run in an infinite loop, not producing any return values. Here is the relevant (I hope, because there are a couple of other classes involved) part of the code; public String listAll() { itr = arrBok.iterator(); while (itr.hasNext()) { i++; } return "lol"; } This code does nothing useful, but I just want to see if it can iterate through it successfully. What I have tried so far; Tested if the bokArr (arraylist) is empty, which it's not. It has 4 objects inside of it. Return the toString() method of the itr, with the following result; java.util.AbstractList$Itr@173a10f // <-- not sure if this would be relevant to anything return itr.next().toString(); <-- // which seems to return the first object in the array, does that make sense?

    Read the article

  • "out of scope" error when iterating an NSMutableArray

    - by wgpubs
    Why am I getting an "out of scope" error whenever I try to access the "url" variable in this loop? for(NSString *url in self.winnerImageURLs) { [mediaItemString appendFormat:@"{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"},", url, url]; } The class of very item in the "self.winnerImageURLs" NSMutableArray comes back as NSCFString so I'm not sure what the dealio is here. Any ideas on what I'm doing wrong??? Thanks

    Read the article

  • Iterating over two arrays at a time in Javascript

    - by Ankur
    I want to iterate over two arrays at the same time, as the values for any given index i in array A corresponds to the value in array B. I am currently using this code, and getting 'undefined' when I call queryPredicates[i] or queryObjects[i], I know my array is populated as I print out the array prior to calling this, I haven't put all the other code in as it might be confusing, but if you think the problem is not evident from this I will edit the question: function getObjectCount(){ variables = queryPredicates.length; //the number of variables is found by the length of the arrays - they should both be of the same length queryString="count="+variables; for(var i=1; i<=variables;i++){ alert(queryPredicates[i]); alert(queryObjects[i]); } Thanks

    Read the article

  • Best way to remove from NSMutableArray while iterating?

    - by Andrew Grant
    In Cocoa, if I want to loop through an NSMutableArray and remove multiple objects that fit a certain criteria, what's the best way to do this without restarting the loop each time I remove an object? Thanks, Edit: Just to clarify - I was looking for the best way, e.g. something more elegant than manually updating the index I'm at. For example in C++ I can do; iterator it = someList.begin(); while (it != someList.end()) { if (shouldRemove(it)) it = someList.erase(it); }

    Read the article

  • JSP Iterating over a map of a list when the value might be null

    - by Brian Hoover
    How do I clear the value from the stack of a s:iterator? I'm trying to iterator over a TreeMultimap with a structure like: TreeMultimap<person, lineItems> persons; Using something like: <s:iterator value="attendeesForParticipantTypeEvents.asMap()"> <div> <s:property value="key.name" /><br /> <s:iterator id="currentSku" value="value"> <s:property value="currentSku.name" /><br /> </s:iterator> </div> </s:iterator> This works fine, except when the treeMultimap has null for lineItems, then it's taking the value from the previous iteration. So, a structure like: persons = {{"Person1",["Line1","line2"]}, {"Person2",["Line3","line4"]}, {"Person2",null}} Renders as: <div> Person1<br /> Line1<br /> Line2<br /> </div> <div> Person2<br /> Line3<br /> Line4<br /> </div> <div> Person3<br /> Line3<br /> Line4<br /> </div> Which seems to indicate that the value isn't being cleared on each iterator. What do I need to do to handle the case where value might be null? Thanks for your help

    Read the article

  • Iterating over member typed collection fails when using untyped reference to generic object

    - by Alexander Pavlov
    Could someone clarify why iterate1() is not accepted by compiler (Java 1.6)? I do not see why iterate2() and iterate3() are much better. This paragraph is added to avoid silly "Your post does not have much context to explain the code sections; please explain your scenario more clearly." protection. import java.util.Collection; import java.util.HashSet; public class Test<T> { public Collection<String> getCollection() { return new HashSet<String>(); } public void iterate1(Test test) { for (String s : test.getCollection()) { // ... } } public void iterate2(Test test) { Collection<String> c = test.getCollection(); for (String s : c) { // ... } } public void iterate3(Test<?> test) { for (String s : test.getCollection()) { // ... } } } Compiler output: $ javac Test.java Test.java:11: incompatible types found : java.lang.Object required: java.lang.String for (String s : test.getCollection()) { ^ Note: Test.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

    Read the article

  • Iterating through child components

    - by ken
    I have button-group component which contains a set of button-element components. The template is defined as: {{#each buttons}} {{button-element titleBinding="title" action="buttonAction"}} {{/each}} I'd like the buttonAction() method in the button-group component to have easy access to the set of button-element components and iterate through them. What's the easiest way to do this? I know I could use a jQuery/DOM approach like: this.$('.btn').doSomething(); But I'd like to address the component objects not the DOM directly.

    Read the article

  • PHP 5.1.6 ArrayAccess error when iterating over object

    - by kenny99
    Hi, I'm having to develop a site on PHP 5.1.6 and I've just come across a bug in my site which isn't happening on 5.2+. When using foreach() to iterate over an object, I get the following error: "Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference..." Does anyone know how to get around this issue? if (strpos($post['feeding_type'], 'comm')) { foreach ($post['commercial_brands'] as $brand) { $comm_food = new Commercial_food_Model; $comm_food->brand = $brand; $comm_food->feeding_type_id = $f_type->id; $comm_food->save(); } }

    Read the article

  • Bash scripting - Iterating through "variable" variable names for a list of associative arrays

    - by user1550254
    I've got a variable list of associative arrays that I want to iterate through and retrieve their key/value pairs. I iterate through a single associative array by listing all its keys and getting the values, ie. for key in "${!queue1[@]}" do echo "key : $key" echo "value : ${queue1[$key]}" done The tricky part is that the names of the associative arrays are variable variables, e.g. given count = 5, the associative arrays would be named queue1, queue2, queue3, queue4, queue5. I'm trying to replace the sequence above based on a count, but so far every combination of parentheses and eval has not yielded much more then bad substitution errors. e.g below: for count in {1,2,3,4,5} do for key in "${!queue${count}[@]}" do echo "key : $key" echo "value : ${queue${count}[$key]}" done done Help would be very much appreciated!

    Read the article

  • Iterating multple lists consecutively (C++)

    - by Graham Rogers
    I have 3 classes, 2 inheriting from the other like so: class A { public: virtual void foo() {cout << "I am A!" << endl;} }; class B : public A { public: void foo() {cout << "B pretending to be A." << endl} void onlyBFoo() {cout << "I am B!" << endl} }; class C : public A { public: void foo() {cout << "C pretending to be A." << endl} void onlyCFoo() {cout << "I am C!" << endl} }; What I want to do is something like this: list<A> list_of_A; list<B> list_of_B; list<C> list_of_C; //put three of each class in their respective list for (list<B>::iterator it = list_of_B.begin(); it != list_of_B.end(); ++it) { (*it).onlyBFoo(); } for (list<C>::iterator it = list_of_C.begin(); it != list_of_C.end(); ++it) { (*it).foo(); } //This part I am not sure about for (list<A>::iterator it = list_of_all.begin(); it != list_of_all.end(); ++it) { (*it).foo(); } To output: I am B! I am B! I am B! I am C! I am C! I am C! I am A! I am A! I am A! B pretending to be A. B pretending to be A. B pretending to be A. C pretending to be A. C pretending to be A. C pretending to be A. Basically, sometimes I want to only loop the Bs and Cs so that I can use their methods, but sometimes I want to loop all of them so that I can use the same method from each i.e. iterate the As, then the Bs, then the Cs all in one loop. I thought of creating a separate list (like the code above) containing everything, but it would create lots of unnecessary maintenance, as I will be adding and removing every object from 2 lists instead of one.

    Read the article

  • Iterating through boost ptr_vector

    - by Ockonal
    Hello, I have a ptr_vector list of my own objects. Something like this: boost::ptr_vector<SomeClass> *list; list.push_back(new SomeClass()>; ... BOOST_FOREACH(SomeClass *tempObj, list) // [x] { tempObj->... } >‘boost::ptr_vector<SomeClass>*’ is not a class, struct, or union type

    Read the article

  • Iterating through items of CompositeCollection

    - by Dudu
    Consider the code: ObservableCollection<string> cities = new ObservableCollection<string>(); ObservableCollection<string> states = new ObservableCollection<string>(); ListBox list; cities.Add("Frederick"); cities.Add("Germantown"); cities.Add("Arlington"); cities.Add("Burbank"); cities.Add("Newton"); cities.Add("Watertown"); cities.Add("Pasadena"); states.Add("Maryland"); states.Add("Virginia"); states.Add("California"); states.Add("Nevada"); states.Add("Ohio"); CompositeCollection cmpc = new CompositeCollection(); CollectionContainer cc1 = new CollectionContainer(); cc1.Collection = cities; CollectionContainer cc2 = new CollectionContainer(); cc2.Collection = states; cmpc.Add(cc1); cmpc.Add(cc2); list.ItemsSource = cmpc; foreach(var itm in cmpc ) { // itm is CollectionContainer and there are only two itm’s // I need the strings } While list shows the right data on the GUI I need this data (without referring to the ListBox) and I am not getting it

    Read the article

  • Iterating ListView items in Android

    - by pocoa
    I want to iterate a list of items into a ListView. This code below is not enough to iterate all the items into the list because of the weird behaviour of getChildCount() function which only returns the visible item count. for (int i = 0; i < list.getChildCount(); i++) { item = (View)list.getChildAt(i); product = (Product)item.getTag(); // make some visual changes if product.id == someProductId } My screen displays 7 results and when there are more than 7 items into the list, it's not possible to access to the 8th item or so.. Only visible items.. Should I use ListIterator instead? Thanks.

    Read the article

  • Iterating through struct fieldnames in MATLAB.

    - by Noio
    My question is easily summarized as: "Why does the following not work?" teststruct = struct('a',3,'b',5,'c',9) fields = fieldnames(teststruct) for i=1:numel(fns) fns(i) teststruct.(fns(i)) end output: ans = 'a' ??? Argument to dynamic structure reference must evaluate to a valid field name. Especially since teststruct.('a') does work. And fns(i) prints out ans = 'a'. I can't get my head around it.

    Read the article

  • Iterating over hashmap in JSP in struts application

    - by Rozer
    I have a HashMap object that I am getting on a JSP page. HashMap<Integer,Gift_product> gift_hm = new HashMap<Integer,Gift_product>(); gift_hm.put(17,new Gift_product("doll",67)); Now I need to iterate this and display content on JSP. The Gift_product class contains two fields: name and price. JSP output should be serial no. product name price 17 Doll 67 How can I achieve it?

    Read the article

  • Threading and iterating through changing collections

    - by adamjellyit
    In C# (console app) I want to hold a collection of objects. All objects are of same type. I want to iterate through the collection calling a method on each object. And then repeat the process continuously. However during iteration objects can be added or removed from the list. (The objects themselves will not be destroyed .. just removed from the list). Not sure what would happen with a foreach loop .. or other similar method. This has to have been done 1000 times before .. can you recommend a solid approach?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >