Search Results

Search found 4036 results on 162 pages for 'nested loops'.

Page 8/162 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Use jQuery's dataTable plugin with a nested Ajax call

    - by mrr0ng
    I am trying to use a nested ajax call to populate a table, and once the table is built, use jQuery's dataTable plugin to pretty it up. The problem I am running into is an order of operations question. When do I call the dataTable function so that I can be assured that the table is built AFTER the values are populated? When I try the following code, the dataTable is created before the rows are built. <script type="text/javascript"> $(document).ready(function() { $.ajax({ url:"http://totalrockregistration.com/feeds/bands.php", dataType:"jsonp", success: function(jsonData){ $.each(jsonData.bands, function(i,bands){ if (bands.barID == "<?php echo $_GET["barID"]; ?>"){ var songIdFromBandJson = bands.song; var bandNameFromJson = bands.name; var bandScoreFromJson = bands.score; $.ajax({ url:"http://totalrockregistration.com/feeds/songs.php", dataType:"jsonp", success: function(songsJsonData){ $.each(songsJsonData.songs, function(i,songs){ if (songIdFromBandJson == songs.id){ var songName=(songs.name); $("#leaderBoardTable tbody").append("<tr><td>"+bandNameFromJson+"</td><td>"+bandScoreFromJson+"</td><td>"+songName+"</td></tr>"); } }); } }); } }); makeLeaderTable(); }, }); function makeLeaderTable(){ $('#leaderBoardTable').dataTable({ "aaSorting": [[ 1, "desc" ]], "iDisplayLength": 50 }); } }); </script>

    Read the article

  • Rails Nested Attributes Doesn't Insert ID Correctly

    - by MunkiPhD
    I'm attempting to edit a model's nested attributes, much as outline here, replicated here: <%= form_for @person do |person_form| %> <%= person_form.text_field :name %> <% for address in @person.addresses %> <%= person_form.fields_for address, :index => address do |address_form|%> <%= address_form.text_field :city %> <% end %> <% end %> <% end %> In my code, I have the following: <%= form_for(@meal) do |f| %> <!-- some other stuff that's irrelevant... --> <% for subitem in @meal.meal_line_items %> <%= f.fields_for subitem, :index => subitem do |line_item_form| %> <%= line_item_form.label :servings %><br/> <%= line_item_form.text_field :servings %><br/> <%= line_item_form.label :food_id %><br/> <%= line_item_form.text_field :food_id %><br/> <% end %> <% end %> <%= f.submit %> <% end %> This works great, except, when I look at the HTML, it's creating the inputs that look like the following, failing to input the correct id and instead placing the memory representation(?) of the model: <input type="text" value="2" size="30" name="meal[meal_line_item][#<MealLineItem:0x00000005c5d618>][servings]" id="meal_meal_line_item_#<MealLineItem:0x00000005c5d618>_servings">

    Read the article

  • Rails: radio button selection for nested forms objects

    - by satynos
    I have the following form for photo_album which uses the nested forms feature of the Rails in saving the photos while updating the photo_album. And having trouble with the selection of radio button value. I want only one of the photos be able to select as the album cover, but due to the way rails produces form element ids and names, I am able to select all of the photos as album covers. Is there any workaround? <% form_for @photo_album do |f| %> <%= f.error_messages %> <% @photo_album.photos.each do |photo| %> <% f.fields_for :photos, photo do |photo_fields| %> <p> <%= image_tag url_for_image_column(photo, "data", :thumb) %> </p> <p> <%= photo_fields.label :title %> <%= photo_fields.text_field :title %> </p> <p> <%= photo_fields.label :body %> <%= photo_fields.text_area :body %> </p> <p> <%= photo_fields.radio_button :cover, "1" %> <%= photo_fields.label :cover, 'Album Cover', :class => 'option' %> <%= photo_fields.check_box :_delete %> <%= photo_fields.label :_delete, 'Delete', :class => 'option' %> </p> <% end %> <% end %> <p> <%= f.submit @photo_album.new_record? ? 'Create' : 'Update' %> </p> <% end %> And following is the html produced by rails (which is part of the problem) for radio buttons: <p> <input type="radio" value="1" name="photo_album[photos_attributes][0][cover]" id="photo_album_photos_attributes_0_cover_1"/> <label for="photo_album_photos_attributes_0_cover" class="option">Album Cover</label> <input type="hidden" value="0" name="photo_album[photos_attributes][0][_delete]"/><input type="checkbox" value="1" name="photo_album[photos_attributes][0][_delete]" id="photo_album_photos_attributes_0__delete"/> <label for="photo_album_photos_attributes_0__delete" class="option">Delete</label> </p>

    Read the article

  • "Can't mass-assign protected attributes" with nested protected models

    - by JohnnyFive
    I'm having a hell of a time trying to get this nested model working. I've tried all manner of pluralization/singular, removing the attr_accessible altogether, and who knows what else. restaurant.rb: # == RESTAURANT MODEL # # Table name: restaurants # # id :integer not null, primary key # name :string(255) # created_at :datetime not null # updated_at :datetime not null # class Restaurant < ActiveRecord::Base attr_accessible :name, :job_attributes has_many :jobs has_many :users, :through => :jobs has_many :positions accepts_nested_attributes_for :jobs, :allow_destroy => true validates :name, presence: true end job.rb: # == JOB MODEL # # Table name: jobs # # id :integer not null, primary key # restaurant_id :integer # shortname :string(255) # user_id :integer # created_at :datetime not null # updated_at :datetime not null # class Job < ActiveRecord::Base attr_accessible :restaurant_id, :shortname, :user_id belongs_to :user belongs_to :restaurant has_many :shifts validates :name, presence: false end restaurants_controller.rb: class RestaurantsController < ApplicationController before_filter :logged_in, only: [:new_restaurant] def new @restaurant = Restaurant.new @user = current_user end def create @restaurant = Restaurant.new(params[:restaurant]) if @restaurant.save flash[:success] = "Restaurant created." redirect_to welcome_path end end end new.html.erb: <% provide(:title, 'Restaurant') %> <%= form_for @restaurant do |f| %> <%= render 'shared/error_messages' %> <%= f.label "Restaurant Name" %> <%= f.text_field :name %> <%= f.fields_for :job do |child_f| %> <%= child_f.label "Nickname" %> <%= child_f.text_field :shortname %> <% end %> <%= f.submit "Done", class: "btn btn-large btn-primary" %> <% end %> Output Parameters: {"utf8"=>"?", "authenticity_token"=>"DjYvwkJeUhO06ds7bqshHsctS1M/Dth08rLlP2yQ7O0=", "restaurant"=>{"name"=>"The Pink Door", "job"=>{"shortname"=>"PD"}}, "commit"=>"Done"} The error i'm receiving is: ActiveModel::MassAssignmentSecurity::Error in RestaurantsController#create Cant mass-assign protected attributes: job Rails.root: /home/johnnyfive/Dropbox/Projects/sa Application Trace | Framework Trace | Full Trace app/controllers/restaurants_controller.rb:11:in `new' app/controllers/restaurants_controller.rb:11:in `create' Anyone have ANY clue how to get this to work? Thanks!

    Read the article

  • Nested attributes form for model which belongs_to few models

    - by ExiRe
    I have few models - User, Teacher and TeacherLeader. class User < ActiveRecord::Base attr_accessible ..., :teacher_attributes has_one :teacher has_one :teacher_leader accepts_nested_attributes_for :teacher_leader end class Teacher < ActiveRecord::Base belongs_to :user has_one :teacher_leader end class TeacherLeader < ActiveRecord::Base belongs_to :user belongs_to :teacher end I would like to fill TeacherLeader via nested attributes. So, i do such things in controller: class TeacherLeadersController < ApplicationController ... def new @user = User.new @teacher_leader = @user.build_teacher_leader @teachers_collection = Teacher.all.collect do |t| [ "#{t.teacher_last_name} #{t.teacher_first_name} #{t.teacher_middle_name}", t.id ] end @choosen_teacher = @teachers_collection.first.last unless @teachers_collection.empty? end end And also have such view (new.html.erb): <%= form_for @user, :url => teacher_leaders_url, :html => {:class => "form-horizontal"} do |f| %> <%= field_set_tag do %> <% f.fields_for :teacher_leader do |tl| %> <div class="control-group"> <%= tl.label :teacher_id, "Teacher names", :class => "control-label" %> <div class="controls"> <%= select_tag( :teacher_id, options_for_select( @teachers_collection, @choosen_teacher )) %> </div> </div> <% end %> <div class="control-group"> <%= f.label :user_login, "Login", :class => "control-label" %> <div class="controls"> <%= f.text_field :user_login, :placeholder => @everpresent_field_placeholder %> </div> </div> <div class="control-group"> <%= f.label :password, "Pass", :class => "control-label" %> <div class="controls"> <%= f.text_field :password, :placeholder => @everpresent_field_placeholder %> </div> </div> <% end %> <%= f.submit "Create", :class => "btn btn-large btn-success" %> <% end %> Problem is that select form here does NOT appear. Why? Do i do something wrong?

    Read the article

  • Improved way to build nested array of unique values in javascript

    - by dualmon
    The setup: I have a nested html table structure that displays hierarchical data, and the individual rows can be hidden or shown by the user. Each row has a dom id that is comprised of the level number plus the primary key for the record type on that level. I have to have both, because each level is from a different database table, so the primary key alone is not unique in the dom. example: id="level-1-row-216" I am storing the levels and rows of the visible elements in a cookie, so that when the page reloads the same rows the user had open are can be shown automatically. I don't store the full map of dom ids, because I'm concerned about it getting too verbose, and I want to keep my cookie under 4Kb. So I convert the dom ids to a compact json object like this, with one property for each level, and a unique array of primary keys under each level: { 1:[231,432,7656], 2:[234,121], 3:[234,2], 4:[222,423], 5:[222] } With this structure stored in a cookie, I feed it to my show function and restore the user's previous disclosure state when the page loads. The area for improvement: I'm looking for better option for reducing my map of id selectors down to this compact format. Here is my function: function getVisibleIds(){ // example dom id: level-1-row-216-sub var ids = $("tr#[id^=level]:visible").map(function() { return this.id; }); var levels = {}; for(var i in ids ) { var id = ids[i]; if (typeof id == 'string'){ if (id.match(/^level/)){ // here we extract the number for level and row var level = id.replace(/.*(level-)(\d*)(.*)/, '$2'); var row = id.replace(/.*(row-)(\d*)(.*)/, '$2'); // *** Improvement here? *** // This works, but it seems klugy. In PHP it's one line (see below): if(levels.hasOwnProperty(level)){ if($.inArray(parseInt(row, 10) ,levels[level]) == -1){ levels[level].push(parseInt(row, 10)); } } else { levels[level] = [parseInt(row, 10)]; } } } } return levels; } If I were doing it in PHP, I'd build the compact array like this, but I can't figure it out in javascript: foreach($ids as $id) { if (/* the criteria */){ $level = /* extract it from $id */; $row = /* extract it from $id */; $levels[$level][$row]; } }

    Read the article

  • Marking multi-level nested forms as "dirty" in Rails

    - by Charles Kihe
    I have a three-level multi-nested form in Rails. The setup is like this: Projects have many Milestones, and Milestones have many Notes. The goal is to have everything editable within the page with JavaScript, where we can add multiple new Milestones to a Project within the page, and add new Notes to new and existing Milestones. Everything works as expected, except that when I add new notes to an existing Milestone (new Milestones work fine when adding notes to them), the new notes won't save unless I edit any of the fields that actually belong to the Milestone to mark the form "dirty"/edited. Is there a way to flag the Milestone so that the new Notes that have been added will save? Edit: sorry, it's hard to paste in all of the code because there's so many parts, but here goes: Models class Project < ActiveRecord::Base has_many :notes, :dependent => :destroy has_many :milestones, :dependent => :destroy accepts_nested_attributes_for :milestones, :allow_destroy => true accepts_nested_attributes_for :notes, :allow_destroy => true, :reject_if => proc { |attributes| attributes['content'].blank? } end class Milestone < ActiveRecord::Base belongs_to :project has_many :notes, :dependent => :destroy accepts_nested_attributes_for :notes, :allow_destroy => true, :allow_destroy => true, :reject_if => proc { |attributes| attributes['content'].blank? } end class Note < ActiveRecord::Base belongs_to :milestone belongs_to :project scope :newest, lambda { |*args| order('created_at DESC').limit(*args.first || 3) } end I'm using an jQuery-based, unobtrusive version of Ryan Bates' combo helper/JS code to get this done. Application Helper def add_fields_for_association(f, association, partial) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(partial, :f => builder) end end I render the form for the association in a hidden div, and then use the following JavaScript to find it and add it as needed. JavaScript function addFields(link, association, content, func) { var newID = new Date().getTime(); var regexp = new RegExp("new_" + association, "g"); var form = content.replace(regexp, newID); var link = $(link).parent().next().before(form).prev(); if (func) { func.call(); } return link; } I'm guessing the only other relevant piece of code that I can think of would be the create method in the NotesController: def create respond_with(@note = @owner.notes.create(params[:note])) do |format| format.js { render :json => @owner.notes.newest(3).all.to_json } format.html { redirect_to((@milestone ? [@project, @milestone, @note] : [@project, @note]), :notice => 'Note was successfully created.') } end end The @owner ivar is created in the following before filter: def load_milestone @milestone = @project.milestones.find(params[:milestone_id]) if params[:milestone_id] end def determine_owner @owner = load_milestone @owner ||= @project end Thing is, all this seems to work fine, except when I'm adding new notes to existing milestones. The milestone has to be "touched" in order for new notes to save, or else Rails won't pay attention.

    Read the article

  • Number nested ordered lists in HTML

    - by John
    Hi I have a nested ordered list. <ol> <li>first</li> <li>second <ol> <li>second nested first element</li> <li>second nested secondelement</li> <li>second nested thirdelement</li> </ol> </li> <li>third</li> <li>fourth</li> </ol> Currently the nested elements start back from 1 again, e.g. first second second nested first element second nested second element second nested third element third fourth What I want is for the second element to be numbered like this: first second 2.1. second nested first element 2.2. second nested second element 2.3. second nested third element third fourth Is there a way of doing this? Thanks

    Read the article

  • nested ordered ol lists in html

    - by John
    Hi I have a nested ordered list. <ol> <li>first</li> <li>second <ol> <li>second nested first element</li> <li>second nested secondelement</li> <li>second nested thirdelement</li> </ol> </li> <li>third</li> <li>fourth</li> </ol> Currently the nested elements start back from 1 again, e.g. first second second nested first element second nested second element second nested third element third fourth What I want is for the second elements to be like this: first second 2.1. second nested first element 2.2. second nested second element 2.3. second nested third element third fourth Is there a way of doing this? Thanks

    Read the article

  • User jQuery to get nested elements from XML

    - by Dkong
    I'm spinning my wheels on this. How do I get the values from the following nested elements from the XML below (I've also put my code below)? I am after the "descShort" value and then the capital "Last" and capital "change" : <indices> <index> <code>DJI</code> <exchange>NYSE</exchange> <liveness>DELAYED</liveness> <indexDesc> <desc>Dow Jones Industrials</desc> <descAbbrev>DOW JONES</descAbbrev> <descShort>DOW JONES</descShort> <firstActive></firstActive> <lastActive></lastActive> </indexDesc> <indexQuote> <capital> <first>11144.57</first> <high>11153.79</high> <low>10973.92</low> <last>11018.66</last> <change>-125.9</change> <pctChange>-1.1%</pctChange> </capital> <gross> <first>11144.57</first> <high>11153.79</high> <low>10973.92</low> <last>11018.66</last> <change>-125.9</change> <pctChange>-1.1%</pctChange> </gross> <totalEvents>4</totalEvents> <lastChanged>16-Apr-2010 16:03:00</lastChanged> </indexQuote> </index> <index> <code>XAO</code> <exchange>ASX</exchange> <liveness>DELAYED</liveness> <indexDesc> <desc>ASX All Ordinaries</desc> <descAbbrev>All Ordinaries</descAbbrev> <descShort>ALL ORDS</descShort> <firstActive>06-Mar-1970</firstActive> <lastActive></lastActive> </indexDesc> <indexQuote> <capital> <first>5007.30</first> <high>5007.30</high> <low>4934.00</low> <last>4939.40</last> <change>-67.9</change> <pctChange>-1.4%</pctChange> </capital> <gross> <first>5007.30</first> <high>5007.30</high> <low>4934.00</low> <last>4939.40</last> <change>-67.9</change> <pctChange>-1.4%</pctChange> </gross> <totalEvents>997</totalEvents> <lastChanged>19-Apr-2010 17:02:54</lastChanged> </indexQuote> </index> $.ajax({ type: "GET", url: "stockindices.xml", dataType: "xml", success: function(xml) { $(xml).find('index').each(function(){ var self = $(this); var code = self.find('indexDesc'); $(code).find('indexDesc').each(function(){ alert(self.find('descShort').text()); }); $('<span class=\"tickerItem\"></span>').html(values[0].text()).appendTo('#marq'); }); } });

    Read the article

  • Implementing Brainf*ck loops in an interpreter

    - by sub
    I want to build a Brainf*ck (Damn that name) interpreter in my freshly created programming language to prove it's turing-completeness. Now, everything is clear so far (<+-,.) - except one thing: The loops ([]). I assume that you know the (extremely hard) BF syntax from here on: How do I implement the BF loops in my interpreter? How could the pseudocode look like? What should I do when the interpreter reaches a loop beginning ([) or a loop end (])? Checking if the loop should continue or stop is not the problem (current cell==0), but: When and where do I have to check? How to know where the loop beginning is located? How to handle nested loops? As loops can be nested I suppose that I can't just use a variable containing the starting position of the current loop. I've seen very small BF interpreters implemented in various languages, I wonder how they managed to get the loops working but can't figure it out.

    Read the article

  • Can I use loops in repeater? Is it reccomended?

    - by iTayb
    My datasource has an Rating dataItem contains an integer from 0 to 5. I'd like to print stars accordignly. I'm trying to do it within Repeater control: <b>Rating:</b> <% for (int j = 1; j <= DataBinder.Eval(Container.DataItem, "Rating"); j++) { %> <img src="App_Pics/fullstar.png" /> <% } for (int j = 1; j <= 5 - DataBinder.Eval(Container.DataItem, "Rating"); j++) { %> <img src="App_Pics/emptystar.png" /> <%} %> I get the error The name 'Container' does not exist in the current context. It is weird, because when I used <%# DataBinder.Eval(Container.DataItem, "Name")%> a line before, it worked great. Is it clever to include loops in my aspx page? I think it's not very convenient. What's my alternatives? What's that # means? Thank you very much.

    Read the article

  • Can I use loops in repeater? Is it recommended?

    - by iTayb
    My datasource has an Rating dataItem contains an integer from 0 to 5. I'd like to print stars accordignly. I'm trying to do it within Repeater control: <b>Rating:</b> <% for (int j = 1; j <= DataBinder.Eval(Container.DataItem, "Rating"); j++) { %> <img src="App_Pics/fullstar.png" /> <% } for (int j = 1; j <= 5 - DataBinder.Eval(Container.DataItem, "Rating"); j++) { %> <img src="App_Pics/emptystar.png" /> <%} %> I get the error The name 'Container' does not exist in the current context. It is weird, because when I used <%# DataBinder.Eval(Container.DataItem, "Name")%> a line before, it worked great. Is it clever to include loops in my aspx page? I think it's not very convenient. What's my alternatives? What's that # means? Thank you very much.

    Read the article

  • How can I increment a counter every N loops in JMeter?

    - by Dave Hunt
    I want to test concurrency, and reliably replicate an issue that JMeter brought to my attention. What I want to do is set a unique identifier (currently the time in milliseconds with a counter appended) and increment the counter between loops but not between threads. The idea being that the number of threads I have set up is the number of identical identifiers before incrementing and using another. If I had 3 threads with a loop count of 2 I want: 1. Unique ID: <current-time-in-millis>000000 2. Unique ID: <current-time-in-millis>000000 3. Unique ID: <current-time-in-millis>000000 4. Unique ID: <current-time-in-millis>000001 5. Unique ID: <current-time-in-millis>000001 6. Unique ID: <current-time-in-millis>000001 I've tried using Throughput Controllers to increment a counter, as well as several other things that seemed they should work but had no luck. This seems like something JMeter should be able to do. Is there any way to get the value of the loop count?

    Read the article

  • R: Are there any alternatives to loops for subsetting from an optimization standpoint?

    - by Adam
    A recurring analysis paradigm I encounter in my research is the need to subset based on all different group id values, performing statistical analysis on each group in turn, and putting the results in an output matrix for further processing/summarizing. How I typically do this in R is something like the following: data.mat <- read.csv("...") groupids <- unique(data.mat$ID) #Assume there are then 100 unique groups results <- matrix(rep("NA",300),ncol=3,nrow=100) for(i in 1:100) { tempmat <- subset(data.mat,ID==groupids[i]) #Run various stats on tempmat (correlations, regressions, etc), checking to #make sure this specific group doesn't have NAs in the variables I'm using #and assign results to x, y, and z, for example. results[i,1] <- x results[i,2] <- y results[i,3] <- z } This ends up working for me, but depending on the size of the data and the number of groups I'm working with, this can take up to three days. Besides branching out into parallel processing, is there any "trick" for making something like this run faster? For instance, converting the loops into something else (something like an apply with a function containing the stats I want to run inside the loop), or eliminating the need to actually assign the subset of data to a variable?

    Read the article

  • Why does the order of the loops affect performance when iterating over a 2D array? [closed]

    - by Mark
    Possible Duplicate: Which of these two for loops is more efficient in terms of time and cache performance Below are two programs that are almost identical except that I switched the i and j variables around. They both run in different amounts of time. Could someone explain why this happens? Version 1 #include <stdio.h> #include <stdlib.h> main () { int i,j; static int x[4000][4000]; for (i = 0; i < 4000; i++) { for (j = 0; j < 4000; j++) { x[j][i] = i + j; } } } Version 2 #include <stdio.h> #include <stdlib.h> main () { int i,j; static int x[4000][4000]; for (j = 0; j < 4000; j++) { for (i = 0; i < 4000; i++) { x[j][i] = i + j; } } }

    Read the article

  • PHP: Formatting multi-dimensional array as HTML?

    - by Industrial
    Hi everybody, I have tried to get my head around building a recursive function to handle formatting of a unknown depth multi-dimensional array to HTML and nested Divs. I thought that it should be a piece of cake, but no. Here's what I have come up with this far: function formatHtml($array) { $var = '<div>'; foreach ($array as $k => $v) { if (is_array($v['children']) && !empty($v['children'])) { formatHtml($v['children']); } else { $var .= $v['cid']; } } $var.= '</div>'; return $var; } And here's my array: Array ( [1] => Array ( [cid] => 1 [_parent] => [id] => 1 [name] => 'Root category' [children] => Array ( [2] => Array ( [cid] => 2 [_parent] => 1 [id] => 3 [name] => 'Child category' [children] => Array () ) ) ) ) Thanks a lot!

    Read the article

  • Problem with routes in functional testing

    - by Wishmaster
    Hi, I'm making a simple test project to prepare myself for my test. I'm fairly new to nested resources, in my example I have a newsitem and each newsitem has comments. The routing looks like this: resources :comments resources :newsitems do resources :comments end I'm setting up the functional tests for comments at the moment and I ran into some problems. This will get the index of the comments of a newsitem. @newsitem is declared in the setup ofc. test "should get index" do get :index,:newsitem_id => @newsitem assert_response :success assert_not_nil assigns(:newsitem) end But the problem lays here, in the "should get new". test "should get new" do get new_newsitem_comment_path(@newsitem) assert_response :success end I'm getting the following error. ActionController::RoutingError: No route matches {:controller=>"comments", :action=>"/newsitems/1/comments/new"} But when I look into the routes table, I see this: new_newsitem_comment GET /newsitems/:newsitem_id/comments/new(.:format) {:action=>"new", :controller=>"comments"} Can't I use the name path or what I'm doing wrong here? Thanks in advance.

    Read the article

  • Nested SQL Select statement fails on SQL Server 2000, ok on SQL Server 2005

    - by Jay
    Here is the query: INSERT INTO @TempTable SELECT UserID, Name, Address1 = (SELECT TOP 1 [Address] FROM (SELECT TOP 1 [Address] FROM [UserAddress] ua INNER JOIN UserAddressOrder uo ON ua.UserID = uo.UserID WHERE ua.UserID = u.UserID ORDER BY uo.AddressOrder ASC) q ORDER BY AddressOrder DESC), Address2 = (SELECT TOP 1 [Address] FROM (SELECT TOP 2 [Address] FROM [UserAddress] ua INNER JOIN UserAddressOrder uo ON ua.UserID = uo.UserID WHERE ua.UserID = u.UserID ORDER BY uo.AddressOrder ASC) q ORDER BY AddressOrder DESC) FROM User u In this scenario, users have multiple address definitions, with an integer field specifying the preferred order. "Address2" (the second preferred address) attempts to take the top two preferred addresses, order them descending, then take the top one from the result. You might say, just use a subquery which does a SELECT for the record with "2" in the Order field, but the Order values are not contiguous. How can this be rewritten to conform to SQL 2000's limitations? Very much appreciated.

    Read the article

  • MVVM pattern and nested view models - communication and lookup lists

    - by LostInWPF
    I am using Prism for a new application that I am creating. There are several lookup lists that will be used in several places in the application. Therefore it makes sense to define it once and use that everywhere I need that functionality. My current solution is to use typed data templates to render the controls inside a content control. <DataTemplate DataType={x:Type ListOfCountriesViewModel}> <ComboBox ItemsSource={Binding Countries} SelectedItem="{Binding SelectedCountry"/> </DataTemplate> <DataTemplate DataType={x:Type ListOfRegionsViewModel}> <ComboBox ItemsSource={Binding Countries} SelectedItem={Binding SelectedRegion} /> </DataTemplate> public class ParentViewModel { SelectedCountry get; set; SelectedRegion get; set; ListOfCountriesViewModel CountriesVM; ListOfRegionsViewModel RgnsVM; } Then in my window I have 2 content controls and the rest of the controls <ContentControl Content="{Binding CountriesVM}"></ContentControl> <ContentControl Content="{Binding RgnsVM}"></ContentControl> <Rest of controls on view> At the moment I have this working and the SelectedItems for the combo boxes are publising events via EventAggregator from the child view models which are then subscribed to in the parent view model. I am not sure that this is the best way to go as I can imagine I would end up with a lot of events very quickly and it will become unwieldy. Also if I was to use the same view model on another window it will publish the event and this parent viewmodel is subscribed to it which could have unintended consequences. My questions are :- Is this the best way to put lookup lists in a view which can be re-used across screens? How do I make it so that the combobox which is bound to the child viewmodel sets the relevant property on the parent viewmodel without using events / mediator. e.g in this case SelectedCountry for example? Any alternative implementation proposals for what I am trying to do? I have a feeling I am missing something obvious and there is so much info it is hard to know what is right so any help would be most gratefully received.

    Read the article

  • jquery nested sortable list

    - by Y.G.J
    i have this code $(document).ready(function() { $("#test-list").sortable({ items: "> li", handle : '.handle', axis: 'y', opacity: 0.6, update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.asp?"+order+"&id=catid&order=orderid&table=tblCats"); } }); $("#test-sub").sortable({ containment: "ul", items: "li", handle : '.handle', axis: 'y', opacity: 0.6, update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.asp?"+order+"&id=catid&order=orderid&table=tblCats"); } }); }); for this kind of UL <ul id="test-list"> <li></li> <li> <ul id="test-sub"> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </li> <li></li> <li></li> <li></li> <li></li> </ul> but it can be changed dynamiclly... when i drag and drop the main li it is working when i do it with the childs it will drag the main one what is wrong?

    Read the article

  • Using nested Master Pages

    - by abatishchev
    Hi. I'm very new to ASP.NET, help me please understand MasterPages conception more. I have Site.master with common header data (css, meta, etc), center form (blank) and footer (copyright info, contact us link, etc). <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="_SiteMaster" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="tagHead" runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> </head> <body> <form id="frmMaster" runat="server"> <div> <asp:ContentPlaceHolder ID="holderForm" runat="server"></asp:ContentPlaceHolder> <asp:ContentPlaceHolder ID="holderFooter" runat="server">Some footer here</asp:ContentPlaceHolder> </div> </form> </body> </html> and I want to use second master page for a project into sub directory, which would contains SQL query on Page_Load for logging (it isn't necessary for whole site). <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %> <asp:Content ContentPlaceHolderID="holderForm" runat="server"> <asp:ContentPlaceHolder ID="holderForm" runat="server" EnableViewState="true"></asp:ContentPlaceHolder> </asp:Content> <asp:Content ContentPlaceHolderID="holderFooter" runat="server"> <asp:ContentPlaceHolder ID="holderFooter" runat="server" EnableViewState="true"></asp:ContentPlaceHolder> </asp:Content> But I have a problem: footer isn't displayed. Where is my mistake? Am I right to use second master page as super class for logging? Project page looks like this: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %> <asp:Content ContentPlaceHolderID="holderForm" runat="server"> <p>Hello World!</p> </asp:Content> <asp:Content ContentPlaceHolderID="holderFooter" runat="Server"> Some footer content </asp:Content>

    Read the article

  • How to use regex to extract nested patterns

    - by Rob Romanek
    Hi I'm struggling with some regex I've got a string like this: a:b||c:{d:e||f:g}||h:i basically name value pairings. I want to be able to parse out the pairings so I get: a:b c:{d:e||f:g} h:i then I can further parse the pairings contained in { } if required It is the nesting that is making me scratch my head. Any regex experts out there that can give me a hand? thanks, Rob

    Read the article

  • Nested Sortable JQuery list doesn't work in IE while it does in FF

    - by Ben Fransen
    Hello everybody, While I'm using this site quite often as a resource for jQuery related problems I can't seem to find an answer this time. So here is my first post. During daytime at work I'm developing an informationsystem for generating MS Word documents. One of the modules I'm developing is for defining a default chapterselection for the table of contents and selecting texts by the given chapters. A user can submit new chapters and if necessary, add them as childchapter to a parent, flag them as 'adopt in TOC' and link a default text (from another module) to the chapter. My chapterlist is retreived recursively from a MySQL table and could look something like this: <ul class="sortableChapterlist"> <li>1</li> <li>2 <ul class="sortableChapterlist"> <li>2.1</li> <li>2.2</li> <li>2.3 <ul class="sortableChapterlist"> <li>2.3.1</li> <li>2.3.2</li> </ul> </li> </ul> </li> </ul> In FireFox the code works like a charm but IE (7) doesn't seem to like it that much. I'm only able to correctly drag arround the mainchapters. When attempting to drag a subchapter, no matter it's level, the correspondending mainchapter lifts up with some child, never all. This is the jQuery code I'm using to accomplish the task: $(function(){ $(".sortableChapterlist").sortable({ opacity: 0.7, helper: 'clone', cursor: 'move' }); $(".sortableChapterlist").selectable(); $(".sortableChapterlist").disableSelection(); }); Does anybody have some ideas about this? I'm guessing IE kinda falls over the multiple class reference "chapter_list" in combination with jQuery trying to handle the draggable/sortable. Kinds regards from Holland, Ben Fransen

    Read the article

  • Nested Routes and Parameters for Rails URLs (Best Practice)

    - by viatropos
    Hey there, I have a decent understanding of RESTful urls and all the theory behind not nesting urls, but I'm still not quite sure how this looks in an enterprise application, like something like Amazon, StackOverflow, or Google... Google has urls like this: http://code.google.com/apis/ajax/ http://code.google.com/apis/maps/documentation/staticmaps/ https://www.google.com/calendar/render?tab=mc Amazon like this: http://www.amazon.com/books-used-books-textbooks/b/ref=sa_menu_bo0?ie=UTF8&node=283155&pf_rd_p=328655101&pf_rd_s=left-nav-1&pf_rd_t=101&pf_rd_i=507846&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=1PK4ZKN4YWJJ9B86ANC9 http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177/ref=sr_1_1?ie=UTF8&s=books&qid=1258755625&sr=1-1 And StackOverflow like this: http://stackoverflow.com/users/169992/viatropos http://stackoverflow.com/questions/tagged/html http://stackoverflow.com/questions/tagged?tagnames=html&sort=newest&pagesize=15 So my question is, what is best practice in terms of creating urls for systems like these? When do you start storing parameters in the url, when don't you? These big companies don't seem to be following the rules so hotly debated in the ruby community (that you should almost never nest URLs for example), so I'm wondering how you go about implementing your own urls in larger scale projects because it seems like the idea of not nesting urls breaks down at anything larger than a blog. Any tips?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >