Search Results

Search found 2858 results on 115 pages for 'nested sortable'.

Page 12/115 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Should nested attributes be automatically deleted when I delete the parent record?

    - by brad
    I'm playing around with nested forms in attributes and have a model Invoice that has_many invoice_phone_numbers. I have the following line in my invoice.rb model file accepts_nested_attributes_for :invoice_phone_numbers, :allow_destroy => true, :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } This does what it should and I can delete invoice_phone_numbers from the form by selecting their 'delete' checkbox. But when I delete an Invoice, I have noticed that the nested invoice_phone_numbers are not also deleted. This causes problems as rails seems to reuse id numbers in the Invoice model (Should it? Does this depend on the database? I'm using SQLite3) so phone numbers from previous invoices turn up in new invoices after they have been created. Anyway, my question is should the nested attributes be deleted when I delete the parent attribute? Is there a way to make this happen automatically as part of the nesting process or do I need to deal with this in my invoice model? If so, what is the best way to do this? I would try to go about this with a before_destroy callback but want to know if this is the best way to do this. Anyway, thanks.

    Read the article

  • how to indicate a change in list elements' order using jquery?

    - by keisimone
    i am using jquery sortable. right now i have a list of items that i can ALREADY use drag and drop. which is cool. i will use a submit button at the bottom of the list to submit the new order. the change in the list is not automatically submitted. All i need is somehow indicate that an element's position has changed. I googled quite a bit. no answer. original list: item1 item2 item3 item4 item5 submitbutton here. changed list: i moved item 2 below item3 for eg. item1 item3 item2 * item4 item5 submitbutton here. how do i use the sortable in jquery for me to display a sign on the item 2? i think should be the change event of sortable but i still do not know how to use it since i am a newbie in jquery. http://docs.jquery.com/UI/Sortable#event-change thank you.

    Read the article

  • PHP Nested classes work... sort of?

    - by SeanJA
    So, if you try to do a nested class like this: //nestedtest.php class nestedTest{ function test(){ class E extends Exception{} throw new E; } } You will get an error Fatal error: Class declarations may not be nested in [...] but if you have a class in a separate file like so: //nestedtest2.php class nestedTest2{ function test(){ include('e.php'); throw new E; } } //e.php class E Extends Exception{} So, why does the second hacky way of doing it work, but the non-hacky way of doing it does not work?

    Read the article

  • Saving jQuery UI Sortable's order to Backbone.js Collection

    - by VirtuosiMedia
    I have a Backbone.js collection that I would like to be able to sort using jQuery UI's Sortable. Nothing fancy, I just have a list that I would like to be able to sort. The problem is that I'm not sure how to get the current order of items after being sorted and communicate that to the collection. Sortable can serialize itself, but that won't give me the model data I need to give to the collection. Ideally, I'd like to be able to just get an array of the current order of the models in the collection and use the reset method for the collection, but I'm not sure how to get the current order. Please share any ideas or examples for getting an array with the current model order.

    Read the article

  • jQuery UL sortable list, CSS how to align column style data

    - by Brett
    Hi, I'm using jQuery UI, sortable on an ul element. All good, except over time the data in my li elements has become table like, in the sense there are multiple columns of data. They aren't aligning correctly because this seems to be hard to do in ul, and indeed not what ul's are designed for. I have 2 choices the way I see Work out some really cool css to make my ul / li format nicely Work out how to convert this to a sortable table With option 2., looking at a few plugins that exist (tablednd for example), they seem very old. I don't believe the jQuery UI Anyone got any recommendations as far as a direction I should head?

    Read the article

  • Ruby on Rails: Simple way to select all records of a nested model?

    - by Josh Pinter
    Just curious, I spent an embarrassing amount of time trying to get an array of all the records in a nested model. I just want to make sure there is not a better way. Here is the setup: I have three models that are nested under each other (Facilities Tags Inspections), producing code like this for routes.rb: map.resources :facilities do |facilities| facilities.resources :tags, :has_many => :inspections end I wanted to get all of the inspections for a facility and here is what my code ended up being: def facility_inspections @facility = Facility.find(params[:facility_id]) @inspections = [] @facility.tags.each do |tag| tag.inspections.each do |inspection| @inspections << inspection end end end It works but is this the best way to do this - I think it's cumbersome. Thanks in advance. Josh

    Read the article

  • Sortable with scriptaculous problems

    - by user195257
    hello, Im following a few tutorials to sort a list, but i can't get the DB to update. The drag drop side of things is working, also, i javascript alert() the serialize list onUpdate and the order is printed out as follows: images_list[]=20&images_list[]=19 etc... So the sorting and dragging is working fine, i just cant get the database to update, this is my code. <script type="text/javascript"> Sortable.create("images_list", { onUpdate: function() { new Ajax.Request("processor.php", { method: "post", parameters: { data: Sortable.serialize("images_list") } }); } }); processor.php code: //Connect to DB require_once('connect.php'); parse_str($_POST['data']); for ($i = 0; $i < count($images_list); $i++) { $id = $images_list[$i]; mysql_query("UPDATE `images` SET `ranking` = '$i' WHERE `id` = '$id'"); } Any ideas would be great, thankyou!

    Read the article

  • BigQuery - UK dev community, JSON, nested/repeated, improved data loading - Live from London

    BigQuery - UK dev community, JSON, nested/repeated, improved data loading - Live from London Join Michael Manoochehri and Ryan Boyd live from London to discuss Strata London and Best Practices for using BigQuery. They'll also host an open Office Hours. Please add your questions to Google Moderator on developers.google.com From: GoogleDevelopers Views: 87 14 ratings Time: 33:00 More in Science & Technology

    Read the article

  • Hierarchies on Steroids #1: Convert an Adjacency List to Nested Sets

    SQL Server MVP Jeff Moden shows us a new very high performance method to convert an "Adjacency List" to “Nested Sets” on a million node hierarchy in less than a minute and 100,000 nodes in just seconds. Not surprisingly, the "steroids" come in a bottle labeled "Tally Table". 12 essential tools for database professionalsThe SQL Developer Bundle contains 12 tools designed with the SQL Server developer and DBA in mind. Try it now.

    Read the article

  • SEO: Nested List vs List, Split Over Divs vs Definition List

    - by Jon P
    From an SEO perspective which, if any, is better: Option 1: Nested lists with h2 tags <ul id="mainpoints"> <li><h2>Powerful Analysis</h2> <ul> <li>Charting and indicators</li> <li>Daily trading signals</li> <li>Company health checks</li> </ul> </li> <li><h2>World Market Data</h2> <ul> [List Items removed for brevity] </ul> </li> <li><h2>Daily Market Data</h2> <ul> [List Items removed for brevity] </ul> </li> </ul> Option 2: Divs with h2 and lists <div id="mainpoints"> <div> <h2>Powerful Analysis</h2> <ul> <li>Charting and indicators</li> <li>Daily trading signals</li> <li>Company health checks</li> </ul> </div> <div> <h2>World Market Data</h2> <ul> [List Items removed for brevity] </ul> </div> <div> <h2>Daily Market Data</h2> <ul> [List Items removed for brevity] </ul> </div> </div> Option 3: Definition List <dl id="mainpoints"> <dt>Powerful Analysis</dt> <dd>- Charting and indicators</dd> <dd>- Daily trading signals</dd> <dd>- Company health checks</dd> <dt>World Market Data</dt> [List Items removed for brevity] <dt>Daily Market Data</dt> [List Items removed for brevity] </dl> My instincts tell me that semanticaly the pure list options (1 & 3) are the best and that h2 may be more SEO friendly (1 & 2) which would point to option 1 as being the best option. I do love the lean makeup of the definition list but will I take an SEO hit by losing the h2 tags? Before anyone asks, h2 is not valid markup in a dt tag. Are my instincts right with a nested list being the way to go?

    Read the article

  • How to use will_paginate with a nested resource in Rails?

    - by Sue Petersen
    I'm new to Rails, and I'm having major trouble getting will_paginate to work with a nested resource. I have two models, Statement and Invoice. will_paginate is working on Statement, but I can't get it to work on Invoice. I know I'd doing something silly, but I can't figure it out and the examples I've found on google won't work for me. statement.rb class Statement < ActiveRecord::Base has_many :invoices def self.search(search, page) paginate :per_page => 19, :page => page, :conditions => ['company like ?', "%#{search}%"], :order => 'date_due DESC, company, supplier' end end statements_controller.rb <irrelevant code clipped for readability> def index #taken from the RAILSCAST 51, will_paginate podcast @statements = Statement.search(params[:search], params[:page]) end I call this in the view like so, and it works: <%= will_paginate @statements %> But I can't figure out how to get it to work for Invoices: invoice.rb class Invoice < ActiveRecord::Base belongs_to :statement def self.search(search, page) paginate :per_page => 19, :page => page, :conditions => ['company like ?', "%#{search}%"], :order => 'employee' end end invoices_controller.rb class InvoicesController < ApplicationController before_filter :find_statement #TODO I can't get will_paginate to work w a nested resource def index #taken from the RAILSCAST 51, will_paginate podcast @invoices = Invoice.search(params[:search], params[:page]) end def find_statement @statement_id = params[:statement_id] return(redirect_to(statements_url)) unless @statement_id @statement = Statement.find(@statement_id) end end And I try to call it like this: <%= will_paginate (@invoices) % The most common error message, as I play with this, is: "The @statements variable appears to be empty. Did you forget to pass the collection object for will_paginate?" I don't have a clue what the problem is, or how to fix it. Thanks for any help and guidance!

    Read the article

  • How to keep a trace of a record inside a nested repeater?

    - by Amokrane
    Hi, I have the following implementation: As you can see I have a repeater (listing the Machines) and a nested repeater (listing the WindowsServices inside each Machine). For each Windows Service I can perform an action using a button. However, to perform this action I need to know which Machine and which WindowsService are concerned. This is my code: protected void Page_Init(object sender, EventArgs e) { rptMachine.ItemDataBound += new RepeaterItemEventHandler(rptMachine_ItemDataBound); } protected void Page_Load(object sender, EventArgs e) { // bind the Machine repeater rptMachine.DataSource = _monitoringService.Machines; rptMachine.DataBind(); } protected void rptMachine_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater nestedRepeater = (Repeater) e.Item.FindControl("rptWindowsService"); nestedRepeater.DataSource = ((IMachine) e.Item.DataItem).WindowsServices; nestedRepeater.DataBind(); Button btnActionInner = null; // bind the action button situated inside the nested repeater foreach(RepeaterItem ri in nestedRepeater.Items) { if((Button)ri.FindControl("btnAction") != null) { btnActionInner = (Button) ri.FindControl("btnAction"); btnActionInner.CommandName = "ActionState"; btnActionInner.CommandArgument = strWindowsService; } } } } protected void rptWindowsService_ItemCommand(object source, RepeaterCommandEventArgs e) { // do the specific action stop/run for the windows service if (e.CommandName == "ActionState") { if(((Button)(e.CommandSource)).Text.Equals("Stop")) { } else if(((Button)(e.CommandSource)).Text.Equals("Run")) { } } } } } So basically I need to know (inside rptWindowsService_ItemCommand) what is the pair that is concerned by the operation. What's the best way to do that? Don't hesitate to ask for more clarifications! Thanks

    Read the article

  • Is There a More Efficient Way to Write Nested While Loops?

    - by Ryan
    The code below shows nested while loops, but it's not the very efficient. Suppose I wanted to extend the code to include 100 nested while loops. Is there a better way to accomplish this task? <?php $count = 1; $num = 1; $options=3; while ( $num <=$options ) { echo "(".$num . ") "; $num1 = 1; $options1=3; while ( $num1 <=$options1 ) { echo "*".$num1 . "* "; $num2 = 1; $options2=3; while ( $num2 <=$options2 ) { echo "@".$num2 . "@ "; $num3 = 1; $options3=3; while ( $num3 <=$options3 ) { echo $num3 . " "; $num3++; $count++; } echo "<br />"; $num2++; } echo "<br />"; $num1++; } echo "<br />"; $num++; } echo $count; ?>

    Read the article

  • Nested Class member function can't access function of enclosing class. Why?

    - by Rahul
    Please see the example code below: class A { private: class B { public: foobar(); }; public: foo(); bar(); }; Within class A & B implementation: A::foo() { //do something } A::bar() { //some code foo(); //more code } A::B::foobar() { //some code foo(); //<<compiler doesn't like this } The compiler flags the call to foo() within the method foobar(). Earlier, I had foo() as private member function of class A but changed to public assuming that B's function can't see it. Of course, it didn't help. I am trying to re-use the functionality provided by A's method. Why doesn't the compiler allow this function call? As I see it, they are part of same enclosing class (A). I thought the accessibility issue for nested class meebers for enclosing class in C++ standards was resolved. How can I achieve what I am trying to do without re-writing the same method (foo()) for B, which keeping B nested within A? I am using VC++ compiler ver-9 (Visual Studio 2008). Thank you for your help.

    Read the article

  • CouchDB: accessing nested structutes in map function

    - by Vegar
    I have a document based on a xml structure that I have stored in a CouchDB database. Some of the keys contains namespaces and are on the form "namespace:key": {"mykey":{nested:key":"nested value"}} In the map function, I want to emit the nested value as a key, but the colon inside the name makes it hard... emit(doc.mykey.nested:key, doc) <-- will not work. Does anyone know how this can be solved?

    Read the article

  • jquery sortable with regexp

    - by Chris Lively
    I am trying to figure out the right regexp to match on list item id's. For example: <ul id="MyList" class="connectedSortable"> <li id="id=1-32">Item 1</li> <li id="id=2_23">Item 2</li> <li id="id=3">Item 3</li> <li id="id=4">Item 4</li> <li id="id=5">Item 5</li> <li id="id=6">Item 6</li> </ul> On the serialize method, I want it to pull everything after the equal sign (=) $(function () { $("#MyList, #OtherList").sortable({ connectWith: '.connectedSortable', update: function () { $("#MyListOrder").val($("#MyList").sortable('serialize', { regexp: '/(.+)[=](.+)/)' })); } }).disableSelection(); }); I tried the above, but that didn't quite work. My regexp expression is wrong and I don't know what it should be. Ideas?

    Read the article

  • What is the best way to add and order to Doctrine Nested Set Trees?

    - by murze
    What is the best way to add a sense of order in Doctrine Nested Sets? The documention contains several examples of how to get al the childeren of a specific node $category->getNode()->getSiblings() But how can I for example: change the position of the fourth sibling to the second position get only the second sibling add a sibling between the second and third child etc... Do I have to manually add and ordercolumn to the model to do these operations?

    Read the article

  • When did C++ get nested classes?

    - by Parappa
    Somehow I never noticed until today that C++ supports nested classes. This surprised me because when I was learning C++ back in the '90s, I specifically remember nested classes being something that Object Pascal and Java had, but which C++ did not. I asked an old programmer friend about it and he concurred that he recalls C++ not having nested classes. Is my recollection of C++ not having nested classes mistaken, or were they actually added to the standard at some point in the past fifteen years? I tried searching Google for information on this topic and I haven't come up with anything helpful yet. It could also be that I'm thinking of nested functions, which Pascal certainly supports but C does not.

    Read the article

  • How would you refactor nested IF Statements?

    - by saunderl
    I was cruising around the programming blogosphere when I happened upon this post about GOTO's: http://giuliozambon.blogspot.com/2010/12/programmers-tabu.html Here the writer talks about how "one must come to the conclusion that there are situations where GOTOs make for more readable and more maintainable code" and then goes on to show an example similar to this: if (Check#1) { CodeBlock#1 if (Check#2) { CodeBlock#2 if (Check#3) { CodeBlock#3 if (Check#4) { CodeBlock#4 if (Check#5) { CodeBlock#5 if (Check#6) { CodeBlock#6 if (Check#7) { CodeBlock#7 } else { rest - of - the - program } } } } } } } The writer then proposes that using GOTO's would make this code much easier to read and maintain. I personally can think of at least 3 different ways to flatten it out and make this code more readable without resorting to flow-breaking GOTO's. Here are my two favorites. 1 - Nested Small Functions. Take each if and its code block and turn it into a function. If the boolean check fails, just return. If it passes, then call the next function in the chain. (Boy, that sounds a lot like recursion, could you do it in a single loop with function pointers?) 2 - Sentinal Variable. To me this is the easyest. Just use a blnContinueProcessing variable and check to see if it is still true in your if check. Then if the check fails, set the variable to false. How many different ways can this type of coding problem be refactored to reduce nesting and increase maintainability?

    Read the article

  • Alternate method to dependent, nested if statements to check multiple states

    - by octopusgrabbus
    Is there an easier way to process multiple true/false states than using nested if statements? I think there is, and it would be to create a sequence of states, and then use a function like when to determine if all states were true, and drop out if not. I am asking the question to make sure there is not a preferred Clojure way to do this. Here is the background of my problem: I have an application that depends on quite a few input files. The application depends on .csv data reports; column headers for each report (.csv files also), so each sequence in the sequence of sequences can be zipped together with its columns for the purposes of creating a smaller sequence; and column files for output data. I use the following functions to find out if a file is present: (defn kind [filename] (let [f (File. filename)] (cond (.isFile f) "file" (.isDirectory f) "directory" (.exists f) "other" :else "(cannot be found)" ))) (defn look-for [filename expected-type] (let [find-status (kind-stat filename expected-type)] find-status)) And here are the first few lines of a multiple if which looks ugly and is hard to maintain: (defn extract-re-values "Plain old-fashioned sub-routine to process real-estate values / 3rd Q re bills extract." [opts] (if (= (utl/look-for (:ifm1 opts) "f") 0) ; got re columns? (if (= (utl/look-for (:ifn1 opts) "f") 0) ; got re data? (if (= (utl/look-for (:ifm3 opts) "f") 0) ; got re values output columns? (if (= (utl/look-for (:ifm4 opts) "f") 0) ; got re_mixed_use_ratio columns? (let [re-in-col-nams (first (utl/fetch-csv-data (:ifm1 opts))) re-in-data (utl/fetch-csv-data (:ifn1 opts)) re-val-cols-out (first (utl/fetch-csv-data (:ifm3 opts))) mu-val-cols-out (first (utl/fetch-csv-data (:ifm4 opts))) chk-results (utl/chk-seq-len re-in-col-nams (first re-in-data) re-rec-count)] I am not looking for a discussion of the best way, but what is in Clojure that facilitates solving a problem like this.

    Read the article

  • Ping Access to a Nested VM !! Plz Help

    - by Shivaramakrishnan
    I have a problem in communication between the host and the nested VM.This is my layout. I have installed KVM on host machine having a single nic interface (public ip) running Ubuntu.On top of this,I have VM running Ubuntu.I have installed KVM in this VM too.I then have a VM inside this running a web server. I am able to ping the host from this web server VM and ssh into it.But from host to VM ,ping is being unsuccessful. The VM (named L1hyp) on host was created using libvirt-manager and has IP of 192.168.122.8. The vswitch interface created at host is in default config (NAT-ed). Its IP is 192.168.122.1. Now this VM is also having a vswitch interface which is in default config (NAT-ed).Its IP is 192.168.100.1. The Web server VM is created on top of this L1hyp VM, is having an IP of 192.168.100.186. The Webserver VM uses 192.168.100.1 as its default gw. The L1hyp uses 192.168.122.1 as its default gw. From Host: ping 192.168.122.8 - SUCCEEDS ping 192.168.122.1 - SUCCEEDS ping 192.168.100.1 - SUCCEEDS ping 192.168.100.186 - FAILS Comes up with Destination Host Unreachable From 192.168.122.1. But there is route to 192.168.100.0/24 subnet from host.Ping to 192.168.100.1 succeeds. From Webserver VM: ping 192.168.100.1 - SUCCEEDS ping 192.168.122.1 - SUCCEEDS SSH from web server VM to host succeeds. Can anyone help me out what needs to be modified to have two way communication between the host and Webserver VM at the earliest? I am pondering over this problem for over a week now.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >