Search Results

Search found 10804 results on 433 pages for 'attribute keys'.

Page 51/433 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • Xpath fails if an element has a a xmlns attribute

    - by Callum Lamb
    Im trying to use xml to parse a .COLLADA file. The problem is I can't seem to use xpath() to access elements if the root tag has a xmlns attribute. For example this works: $string = <<<TEST <?xml version="1.0" encoding="utf-8"?> <COLLADA version="1.4.1"> <library_materials> <material id="Material" name="Material"> <instance_effect url="#Material-effect"/> </material> <material id="Material2" name="Material"> <instance_effect url="#Material-effect2"/> </material> </library_materials> </COLLADA> TEST; $lol = new SimpleXMLElement($string); print_r($lol->library_materials->xpath("material[@id='Material2']")); But this doesn't: $string = <<<TEST <?xml version="1.0" encoding="utf-8"?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <library_materials> <material id="Material" name="Material"> <instance_effect url="#Material-effect"/> </material> <material id="Material2" name="Material"> <instance_effect url="#Material-effect2"/> </material> </library_materials> </COLLADA> TEST; $lol = new SimpleXMLElement($string); print_r($lol->library_materials->xpath("material[@id='Material2']")); How does the xmlns suddenly make the xml tree unusable? I thought it just defined the namespace so you could tell it apart from other identical tags in other namespaces. What am I missing?

    Read the article

  • Applying the Hibernate filter attribute to a Bag with a many-to-many relationship

    - by David P
    Consider the following Hibernate mapping file: <hibernate-mapping ...> <class name="ContentPackage" table="contentPackages"> <id name="Id" column="id" type="int"><generator class="native" /></id> ... <bag name="Clips" table="contentAudVidLinks"> <key column="fk_contentPackageId"></key> <many-to-many class="Clip" column="fk_AudVidId"></many-to-many> <filter name="effectiveDate" condition=":asOfDate BETWEEN startDate and endDate" /> </bag> </class> </hibernate-mapping> When I run the following command: _session.EnableFilter("effectiveDate").SetParameter("asOfDate", DateTime.Today); IList<ContentPackage> items = _session.CreateCriteria(typeof(ContentPackage)) .Add(Restrictions.Eq("Id", id)) .List<ContentPackage>(); The resulting SQL has the WHERE clause on the intermediate mapping table (contentAudVidLinks), rather than the "Clips" table even though I have added the filter attribute to the Bag of Clips. What am I doing wrong?

    Read the article

  • How to change attribute on Scala XML Element

    - by Dave
    I have an XML file that I would like to map some attributes of in with a script. For example: <a> <b attr1 = "100" attr2 = "50"> </a> might have attributes scaled by a factor of two: <a> <b attr1 = "200" attr2 = "100"> </a> This page has a suggestion for adding attributes but doesn't detail a way to map a current attribute with a function (this way would make that very hard): http://www.scalaclass.com/book/export/html/1 What I've come up with is to manually create the XML (non-scala) linked-list... something like: // a typical match case for running thru XML elements: case Elem(prefix, e, attributes, scope, children @ _*) => { var newAttribs = attributes for(attr <- newAttribs) attr.key match { case "attr1" => newAttribs = attribs.append(new UnprefixedAttribute("attr1", (attr.value.head.text.toFloat * 2.0f).toString, attr.next)) case "attr2" => newAttribs = attribs.append(new UnprefixedAttribute("attr2", (attr.value.head.text.toFloat * 2.0f).toString, attr.next)) case _ => } Elem(prefix, e, newAttribs, scope, updateSubNode(children) : _*) // set new attribs and process the child elements } Its hideous, wordy, and needlessly re-orders the attributes in the output, which is bad for my current project due to some bad client code. Is there a scala-esque way to do this?

    Read the article

  • After Adding "readonly" attribute on text box not able to remove it in one event

    - by Sreedhar K
    Steps to repro USE Internet Explorer Check unlimited check box Click on text box (It will remove tick/check from check box) Try to enter text in text box We cannot enter in the text box 4. Click again on the text box. Now we will be able to enter text in the text box We tried by 1. Making attribute readOnly to flase i.e. $('#myinput').attr('readOnly', false); 2. Calling $('#myinput').click(); Below is the HTML code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Make input read only</title> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js"></script> </head> <body> <input id="myinput" type="text" /> <input id="mycheck" type="checkbox" /> <script type="text/javascript"> /*oncheck box click*/ $('#mycheck').click(function () { if ($(this).attr('checked')) { $('#myinput').attr('readOnly', 'readOnly'); } else { $('#myinput').removeAttr('readOnly'); /* also tried * $('#myinput').attr('readOnly', false); * $('#myinput').attr('readOnly', ''); */ } }); /*on text box click*/ $('#myinput').click(function () { $('#mycheck').removeAttr('checked'); $('#myinput').removeAttr('readOnly'); /* also tried * $('#myinput').attr('readOnly', false); * $('#myinput').attr('readOnly', ''); */ }); </script> </body> </html> Live copy

    Read the article

  • Database relationships using phpmyAdmin (composite keys)

    - by Cool Hand Luke UK
    Hi, I hope this question is not me being dense. I am using phpmyAdmin to create a database. I have the following four tables. Don't worry about that fact place and price are optional they just are. Person (Mandatory) Item (Mandatory) Place (Optional) Price (Optional) Item is the main table. It will always have person linked. * I know you do joins in mysql for the tables. If I want to link the tables together I could use composite keys (using the ids from each table), however is this the most correct way to link the tables? It also means item will have 5 ids including its own. This all cause null values (apparently a big no no, which I can understand) because if place and price are optional and are not used on one entry to the items table I will have a null value there. Please help! Thanks in advance. I hope this makes sense.

    Read the article

  • Cannot get new product attribute in grid display

    - by russjman
    I added a new attribute to my products(a boolean "yes/no" field). It is a variable to enable/disable the price from displaying on the product detail page, and grid view. I managed to get it work on the product info page. But on product grid page I cant seem to access that variable. Specifically, the template i am working with is catalog/product/price.phtml. From what i can tell, the price is being displayed by the same group of if-statements on both the product detail page, and grid page. This has me confused because i cant find any code on that template to handle multiple products, just a bunch of nested if statements. this is how im attempting to access this new variable using $_displayPrice. on line 36 of catalog/product/price.html <?php $_product = $this->getProduct(); ?> <?php $_id = $_product->getId() ?> <?php $_displayPrice = $_product->getDisplayPrice() ? "Yes" : "No"; echo $_displayPrice;?> What has me further confused is that when display $_product-getData(), my new variable isn't anywhere among that data. thanks in advance

    Read the article

  • Suppressing PostSharp Multicast with Attribute

    - by Dan Bryant
    I've recently started experimenting with PostSharp and I found a particularly helpful aspect to automate implementation of INotifyPropertyChanged. You can see the example here. The basic functionality is excellent (all properties will be notified), but there are cases where I might want to suppress notification. For instance, I might know that a particular property is set once in the constructor and will never change again. As such, there is no need to emit the code for NotifyPropertyChanged. The overhead is minimal when classes are not frequently instantiated and I can prevent the problem by switching from an automatically generated property to a field-backed property and writing to the field. However, as I'm learning this new tool, it would be helpful to know if there is a way to tag a property with an attribute to suppress the code generation. I'd like to be able to do something like this: [NotifyPropertyChanged] public class MyClass { public double SomeValue { get; set; } public double ModifiedValue { get; private set; } [SuppressNotify] public double OnlySetOnce { get; private set; } public MyClass() { OnlySetOnce = 1.0; } }

    Read the article

  • Apply shortcut keys to sliverlight page

    - by sankar
    Hi.. In application requirement is as follows.. In the Silverlight child page(Usercontrol, when you click menu item )open page it requires to fill some data then for saving we have Save button for cancel it we have Cancel button. Here i am looking for Saving data i need to use ShortCut Keys(Ctrl + S). If i write the following code in KeyDown event it is not Functioning well, because Generally we punch the 'Ctrl' key in Presssed mode and then we punch the "S" key here if i punch 'Ctrl' key is not released then it is not working.. Otherwise ie. if punch "Ctrl" key then release it then punch "S" it is working fine.. //Code //int count=0;--Global--- protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.Key == Key.Ctrl) { count = 1; } string str = e.Key.ToString(); if (count >0 && str == "S") { //MessageBox.Show("Saved"); //Saving the data count = 0; } } I am looking for it works on With "Ctrl" key is in pressed mode please look into this... Thanks

    Read the article

  • 'NoneType' object has no attribute 'data'

    - by Bill Jordan
    Hello guys, I am sending a SOAP request to my server and getting the response back. sample of the response string is shown below: <?xml version = '1.0' ?> <env:Envelope xmlns:env=http:////www.w3.org/2003/05/soap-envelop . .. .. <env:Body> <epas:get-all-config-resp xmlns:epas="urn:organization:epas:soap"> ^M ... ... <epas:property name="Tom">12</epas:property> > > <epas:property name="Alice">34</epas:property> > > <epas:property name="John">56</epas:property> > > <epas:property name="Danial">78</epas:property> > > <epas:property name="George">90</epas:property> > > <epas:property name="Luise">11</epas:property> ... ^M </env:Body? </env:Envelop> What I noticed in the response is that there is an extra character shown in the body which is "^M". Not sure if this could be the issue. Note the ^M shown! when I tried parsing the string returned from the server to get the names and values using the code sample: elements = minidom.parseString(xmldoc).getElementsByTagName("property") myDict = {} for element in elements: myDict[element.getAttribute('name')] = element.firstChild.data But, I am getting this error: 'NoneType' object has no attribute 'data'. May be its something to do with the "^M" shown on the xml response back! Any ideas/comments would be appreciated, Cheers

    Read the article

  • define keys in multidimensional array from csv

    - by mourique
    I want to compare two arrays, one coming from a shoppingcart and the other one parsed from a csv-file. The array from the shopping cart looks like this: Array ( [0] => Array ( [id] => 7 [qty] => 1 [price] => 07.39 [name] => walkthebridge [subtotal] => 7.39 ) [1] => Array ( [id] => 2 [qty] => 1 [price] => 07.39 [name] => milkyway [subtotal] => 7.39 ) ) The array from my csv-file however looks like this Array ( [0] => Array ( [0] => 1 [1] => walkthebridge [2] => 07.39 ) [1] => Array ( [0] => 2 [1] => milkyway [2] => 07.39 ) ) and is build using this code $checkitems = array(); $file = fopen('checkitems.csv', 'r'); while (($result = fgetcsv($file)) !== false) { $checkitems[] = $result; } fclose($file); how can i get the keys in the second array to match those in the first one? ( So that 0 would be id, and 1 would be name and so on) thanks in advance

    Read the article

  • XSLT: generate multiple object by incrementing attribute and value

    - by Daniel
    Hi, I have a xml as below that I'd like to copy n times while incrementing one of its element and one of its attribute. XML input: <Person position=1> <name>John</name> <number>1</number> <number>1</number> </Person> and I'd like something like below with the number of increment to be a variable. XML output: <Person position=1> <name>John</name> <number>1</number> </Person> <Person position=2> <name>John</name> <number>2</number> </Person> .... <Person position=n> <name>John</name> <number>n</number> </Person> Any clue

    Read the article

  • Give a reference to a python instance attribute at class definition

    - by Guenther Jehle
    I have a class with attributes which have a reference to another attribute of this class. See class Device, value1 and value2 holding a reference to interface: class Interface(object): def __init__(self): self.port=None class Value(object): def __init__(self, interface, name): self.interface=interface self.name=name def get(self): return "Getting Value \"%s\" with interface \"%s\""%(self.name, self.interface.port) class Device(object): interface=Interface() value1=Value(interface, name="value1") value2=Value(interface, name="value2") def __init__(self, port): self.interface.port=port if __name__=="__main__": d1=Device("Foo") print d1.value1.get() # >>> Getting Value "value1" with interface "Foo" d2=Device("Bar") print d2.value1.get() # >>> Getting Value "value1" with interface "Bar" print d1.value1.get() # >>> Getting Value "value1" with interface "Bar" The last print is wrong, cause d1 should have the interface "Foo". I know whats going wrong: The line interface=Interface() line is executed, when the class definition is parsed (once). So every Device class has the same instance of interface. I could change the Device class to: class Device(object): interface=Interface() value1=Value(interface, name="value1") value2=Value(interface, name="value2") def __init__(self, port): self.interface=Interface() self.interface.port=port So this is also not working: The values still have the reference to the original interface instance and the self.interface is just another instance... The output now is: >>> Getting Value "value1" with interface "None" >>> Getting Value "value1" with interface "None" >>> Getting Value "value1" with interface "None" So how could I solve this the pythonic way? I could setup a function in the Device class to look for attributes with type Value and reassign them the new interface. Isn't this a common problem with a typical solution for it? Thanks!

    Read the article

  • Can't set Visible attribute in ASP.NET Panels

    - by RichW
    I am having trouble with visible attribute of an ASP.NET Panel control. I have a page that calls a database table and returns the results in a datagrid. Requirements If some of the returned values are null I need to hide the image that's next to it. I am using a Panel to determine whether to hide or show the image but am having trouble with the statement: visible='<%# Eval("addr1") <> DBNull.Value %>' I have tried these as well: visible='<%# Eval("addr1") <> DBNull.Value %>' visible='<%# IIf(Eval("addr1") Is DbNull.Value, "False","True") %>' Code is below: <asp:TemplateField > <ItemTemplate> <%# Eval("Name")%> <p> <asp:Panel runat="server" ID="Panel1" visible='<%# Eval("addr1") <> DBNull.Value %>'> <asp:Image Id="imgHouse" runat="server" AlternateText="Address" SkinId="imgHouse"/> </asp:Panel> <%# Eval("addr1") %><p> </ItemTemplate> </asp:TemplateField> What am I doing wrong? Edit If I use visible='<%# IIf(Eval("addr1") Is DbNull.Value, "False","True") %>' I get the following error: Compiler Error Message: CS1026: ) expected

    Read the article

  • Selecting a div with same ID as the rel attribute of clicked link

    - by Chris
    Hi there, This is a two-part question. I'm using jQuery for a project and wanting to click a link and toggle the class name "highlight" to that link and also to the div with the same id as the rel attribute of the link. I then want to be able to link to the next div without the classname of "highlight". Here's the HTML for it: <ul> <li><a href="#" rel="panel1">Item 1</a></li> <li><a href="#" rel="panel2">Item 2</a></li> <li><a href="#" rel="panel3">Item 3</a></li> </ul> <a href="">go to next div without class of highlight</a> <div id="panel1">some text</div> <div id="panel2">some text</div> <div id="panel3">some text</div> Can anyone help with jQuery side of things? Many thanks in advance!

    Read the article

  • IE ignores added onclick attribute

    - by user357034
    The Jquery code below works ok with firefox, Safari, Opera but not with IE. I kinda know why this isn't working in IE after reading a lot about it but I do not know how to fix it. My understanding (I think) is that this method will assign a attribute of "onclick" in IE rather than an event method. Therefore it will not fire in IE and the href fires instead which in this case is "#" which is exactly what is happening. What is the correct way of adding the onclick event. <a id="product_photo_zoom_url" href="/PhotoGallery.asp?ProductCode=9857%2D116%2D003" title="9857-116-003 Ignition box"><img id="product_photo" src="/v/vspfiles/photos/9857-116-003-2T.jpg" border="0" alt="9857-116-003 Ignition box" /></a> <br /><a id="product_photo_zoom_url2" href="/PhotoGallery.asp?ProductCode=9857%2D116%2D003" title="9857-116-003 Ignition box"> <img src="/v/vspfiles/templates/100/images/buttons/btn_largerphoto.gif" border="0"></a> var global_URL_Encode_Current_ProductCode; var global_Config_ProductPhotosFolder; var global_Current_ProductCode; var titleattr = $("a#product_photo_zoom_url").attr("title"); var picurl='tb_show(titleattr, \'/PhotoDetails.asp?ShowDESC=N&ProductCode=\' + global_URL_Encode_Current_ProductCode + \'&TB_iframe=true&height=600&width=520\');return false;' $("a#product_photo_zoom_url").attr('onclick', picurl); $("a#product_photo_zoom_url").attr('href', '#'); $("a#product_photo_zoom_url2").attr('onclick', picurl); $("a#product_photo_zoom_url2").attr('href', '#');

    Read the article

  • XSD: Different sub-elements depending on attribute/element value

    - by AndiDog
    Another XSD question - how can I achieve that the following XML elements are both valid: <some-element> <type>1</type> <a>...</a> </some-element> <some-element> <type>2</type> <b>...</b> </some-element> The sub-elements (either <a> or <b>) should depend on the content of <type> (could also be an attribute). It would be so simple in RelaxNG - but RelaxNG doesn't support key integrity :( Is there a way to implement this in XSD? Note: XML schema version 1.1 supports <xs:alternative>, which might be a solution, but afaik no reference implementation (e.g. libxml2) supports this yet. So I'm searching for workarounds. The only way I've come up with is: <type>1</type> <some-element type="1"> <!-- simple <xs:choice> between <a> and <b> goes here --> <a>...</a> </some-element> <!-- and now create a keyref between <type> and @type -->

    Read the article

  • [Rails] checkbox to update attribute

    - by Jeff
    [Updated a bit] I have a Task model that has a :completed boolean attribute. If I click on it I want it to execute the 'finish' method. The main problem is that I am displays a series of checkboxes in a list and subsequent checkboxes after the first one are ignored. The method is never called for the given task/checkbox combo. I have this chunk of code in my view: <% current_user.tasks.each do |t|%> <% if t.completed == false %> <%= check_box_tag :completed, true, checked = false %> <%= observe_field :completed, :url => { :controller => 'tasks', :action => :finish , :id => t.id }, :frequency => 0.25, :update => :completed, :with => true %> and my finish method looks like this: def finish @task = Task.find(params[:id]) new = {:completed => true} @task.update_attributes(new) render :update do |page| page.replace_html "taskListing", :partial => 'home/task_listing' end

    Read the article

  • Howto: Access a second related model in a nested attribute builder block

    - by Joe Cairns
    I have a basic has_many through relationship: class Foo < ActiveRecord::Base has_many :bars, :dependent => :destroy has_many :wtfs :through => :bars accepts_nested_attributes_for :bars, :wtfs end On my crud forms I have a builder block for the wtf, but I need the label to come from the bar (an attribute called label for instance). What's the proper method to do this? Here's the most simple scaffold: <h1>New foo</h1> <% form_for(@foo) do |f| %> <%= f.error_messages %> <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <h2>Bars</h2> <% f.fields_for :wtfs do |builder| %> <%= builder.hidden_field :bar_id %> <p> <%= builder.text_field :wtf_data_i_need_to_set %> </p> <% end %> <p> <%= f.submit 'Create' %> </p> <% end %> <%= link_to 'Back', foos_path %>

    Read the article

  • Ruby on Rails unknown attribute form error

    - by Ulkmun
    I'm attempting to create a form which will allow me to upload a file.. I've got the following form.. <div class="field"> <%= f.label :title %><br /> <%= f.text_field :title %> </div> <div class="field"> <%= f.label :body %><br /> <%= f.text_area :body, "cols" => 100, "rows" => 40 %> </div> <div class="field"> <%= f.label :upload %><br /> <%= f.file_field :upload %> </div> <div class="actions"> <%= f.submit %> </div> I've got a controller which seems to error in this function.. # POST /posts # POST /posts.xml def create @post = Post.new(params[:post]) @post = DataFile.save(params[:upload]) ##render :text => "File has been uploaded successfully" respond_to do |format| if @post.save format.html { redirect_to(@post, :notice => 'Post was successfully created.') } format.xml { render :xml => @post, :status => :created, :location => @post } else format.html { render :action => "new" } format.xml { render :xml => @post.errors, :status => :unprocessable_entity } end end end That's the method that get's called when I create the post. The error is unknown attribute: upload app/controllers/posts_controller.rb:42:in ``new' app/controllers/posts_controller.rb:42:in ``create'

    Read the article

  • Apply [ThreadStatic] attribute to a method in external assembly

    - by Sen Jacob
    Can I use an external assembly's static method like [ThreadStatic] method? Here is my situation. The assembly class (which I do not have access to its source) has this structure public class RegistrationManager() { private RegistrationManager() {} public static void RegisterConfiguration(int ID) {} public static object DoWork() {} public static void UnregisterConfiguration(int ID) {} } Once registered, I cannot call the DoWork() with a different ID without unregistering the previously registered one. Actually I want to call the DoWork() method with different IDs simultaneously with multi-threading. If the RegisterConfiguration(int ID) method was [ThreadStatic], I could have call it in different threads without problems with calls, right? So, can I apply the [ThreadStatic] attribute to this method or is there any other way I can call the two static methods same time without waiting for other thread to unregister it? If I check it like the following, it should work. for(int i=0; i < 10; i++) { new Thread(new ThreadStart(() => Checker(i))).Start(); } public string Checker(int i) { public static void RegisterConfiguration(i); // Now i cannot register second time public static object DoWork(i); Thread.Sleep(5000); // DoWork() may take a little while to complete before unregistered public static void UnregisterConfiguration(i); }

    Read the article

  • what's the performance difference between int and varchar for primary keys

    - by user568576
    I need to create a primary key scheme for a system that will need peer to peer replication. So I'm planning to combine a unique system ID and a sequential number in some way to come up with unique ID's. I want to make sure I'll never run out of ID's, so I'm thinking about using a varchar field, since I could always add another character if I start running out. But I've read that integers are better optimized for this. So I have some questions... 1) Are integers really better optimized? And if they are, how much of a performance difference is there between varchars and integers? I'm going to use firebird for now. But I may switch later. Or possibly support multiple db's. So I'm looking for generalizations, if that's possible. 2) If integers are significantly better optimized, why is that? And is it likely that varchars will catch up in the future, so eventually it won't matter anyway? My varchar keys won't have any meaning, except for the unique system ID part. But I may want to obscure that somehow. Also, I plan to efficiently use all the bits of each character. I don't, for example, plan to code the integer 123 as the character string "123". So I don't think varchars will require more space than integers.

    Read the article

  • Grouping arrays with consecutive keys

    - by KPL
    Hello people, I've an array like this - Array ( [16] => 424 [17] => 404 [18] => 416 [21] => 404 [22] => 456 [23] => 879 [28] => 456 [29] => 456 [32] => 123 [35] => 465 ) The output of this array would be Array ( [0] => Array ( ['start'] => 16 ['stop'] => 18 ) [1] => Array ( ['start'] => 21 ['stop'] => 23 ) [2] => Array ( ['start'] => 28 ['stop'] => 29 ) [3] => Array ( ['start'] => 32 ['stop'] => 33 ) [4] => Array ( ['start'] => 35 ['stop'] => 36 ) ) I don't really need the values. Just grouping the keys. And if consecutive integer doesn't exist for a particular key(like for [32] and [35]), 'stop' should be the consecutive integer. Thank you all for help.

    Read the article

  • Changing the href attribute on hover with jQuery

    - by AverageJoe
    Ok, I have an html page that is loaded into another html page via PHP (ok so its a PHP page, whatever). The page that is loaded is a list of hyperlinks. I need to change the href attribute to make the hyperlinks relative to the location of the stored images they refer too. When i load the page containing the hyperlinks the links are relative to the web host server, not the server that the page is actually hosted from. Somthing like this: <div #screenshots) <p><a href="image1.htm">Image1</a></p> <p><a href="image2.htm">Image2</a></p> <p><a href="image3.htm">Image3</a></p> <p><a href="image4.htm">Image4</a></p> <p><a href="image5.htm">Image5</a></p> </div> When I mouse over the links, the status bar shows the reference as "http://webHostServer.com/image1.htm". If I click it I get a 404 error. I need the href to change to something like this when I mouse over it: "http://www.actualImageHostServerIPaddress/image1.htm" I looked at this for assitance and came out with the following jQuery code, but for some reason none of it works: $(document).ready(function(){ $("button").click(function() { $("#screenshots a").addClass('ss'); }); $(".ss").each(function() { $(this).data("oldHref", $(this).attr("href")); orig = $(this).attr("href"); over = "http://208.167.244.33/208.167.244.33/"; $(this).hover(function() { $(this).attr("href", $(this).attr("href").replace(orig, over+orig)); }, function() { $(this).attr("href", $(this).data("oldHref")); }); }); When I click the button it dosen't add the class to the anchor tags, so when I hover over them nothing changes. Any help here would be great.

    Read the article

  • Rails : can't write unknown attribute `url'

    - by user2954789
    I am new to ruby on rails,and I am learning by creating a blog. I am not able to save to my blogs table and I get this error "can't write unknown attribute url" Blogs migration :db/migrate/ class CreateBlogs < ActiveRecord::Migration --def change --- create_table :blogs do |t| ---- t.string :title ---- t.text :description ---- t.string :slug ---- t.timestamps --- end --end end Blogs Model :/app/models/blogs.rb class Blogs < ActiveRecord::Base --acts_as_url :title --def to_param ---url --end --validates :title, presence:true end Blogs Controller : /app/controllers/blogs_controller.rb class BlogsController < ApplicationController before_action :require_login --def new --- @blogs = Blogs.new --end --def show ---@blogs = Blogs.find(params[:id]) --end --def create ---@blogs = Blogs.new(blogs_params) --if @blogs.save ---flash[:success] = "Your Blog has been created." ---redirect_to home_path --else ---render 'new' --end -end --def blogs_params ---params.require(:blogs).permit(:title,:description) --end private --def require_login ---unless signed_in? ----flash[:error] = "You must be logged in to create a new Blog" ----redirect_to signin_path ---end --end end Blogs Form:/app/views/blogs/new.html.erb Blockquote <%= form_for @blogs, url: blogs_path do |f| %><br/> <%= render 'shared/error_messages_blogs' %><br/> <%= f.label :title %><br/> <%= f.text_field :title %><br/> <%= f.label :description %><br/> <%= f.text_area :description %><br/> <%= f.submit "Submit Blog", class: "btn btn-large btn-primary" %><br/> <% end %><br/> and I have also added "resources :blogs" to my routes.rb file. I get this error in controller at if @blogs.save

    Read the article

  • Enum.TryParse with Flags attribute

    - by Sunny
    I have written code to TryParse enum either by value or by its name as shown below. How can I extend this code to include parsing enums with Flags attribute? public static bool TryParse<T>(this T enum_type, object value, out T result) where T : struct { return enum_type.TryParse<T>(value, true, out result); } public static bool TryParse<T>(this T enum_type, object value, bool ignoreCase, out T result) where T : struct { result = default(T); var is_converted = false; var is_valid_value_for_conversion = new Func<T, object, bool, bool>[]{ (e, v, i) => e.GetType().IsEnum, (e, v, i) => value != null, (e, v, i) => Enum.GetNames(e.GetType()).Any(n => String.Compare(n, v.ToString(), i) == 0) || Enum.IsDefined(e.GetType(), v) }; if(is_valid_value_for_conversion.All(rule => rule(enum_type, value, ignoreCase))){ result = (T)Enum.Parse(typeof(T), value.ToString(), ignoreCase); is_converted = true; } return is_converted; } Currently this code works for the following enums: enum SomeEnum{ A, B, C } // can parse either by 'A' or 'a' enum SomeEnum1 : int { A = 1, B = 2, C = 3 } // can parse either by 'A' or 'a' or 1 or "1" Does not work for: [Flags] enum SomeEnum2 { A = 1, B = 2, C = 4 } // can parse either by 'A' or 'a' // cannot parse for A|B Thanks!

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >