Search Results

Search found 4827 results on 194 pages for 'alert'.

Page 25/194 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • jQuery Colorbox Iframe and Selector

    - by Joker
    I have this: $("a.money").colorbox({href:$("a.money").attr("href")+" div#content"}); Which opens an overlay but only of the content within the #content selector. If I add iframe:true, this will no longer work. Is there a way to get it to work with an iframe? Edit: The closest I could get it to work was by doing this: $("a.money").colorbox({iframe:true, width:700, height:425, onComplete: function() { alert('test'); $test = $("#cboxLoadedContent iframe").contents().find("#content").html(); $("#cboxLoadedContent iframe").contents().find("#container").html($test); } }); Although without the alert it doesn't appear to work, I looked into that and I think I need to use .live(), which led me to trying this: $('a.money').live('click', function() { url = this.href; // this is the url of the element event is triggered from $.fn.colorbox({href: url, iframe:true,width:700, height:425, onComplete: function() { $test = $("#cboxLoadedContent iframe").contents().find("#content").html(); $("#cboxLoadedContent iframe").contents().find("#container").html($test); } }); return false; }); Didn't work, I still needed to add an alert to make it work. In case you might be wondering what I'm trying to do. The webpage is loaded in the iframe, with all the elements in the #container, so that includes #header, #sidebars, but I only want to show the #content inside the iframe. However, this led me to another problem I realized. Assuming I got this to work without the alert, it will only work for that initial page. For example, if I loaded up a form in the iframe, after submitting the form, I would once again see the whole layout instead of just the #content portion. Is it possible to continue only showing the #content portion of the page upon further navigation?

    Read the article

  • OO Design / Patterns - Fat Model Vs Transaction Script?

    - by ben
    Ok, 'Fat' Model and Transaction Script both solve design problems associated with where to keep business logic. I've done some research and popular thought says having all business logic encapsulated within the model is the way to go (mainly since Transaction Script can become really complex and often results in code duplication). However, how does this work if I want to use the TDG of a second Model in my business logic? Surely Transaction Script presents a neater, less coupled solution than using one Model inside the business logic of another? A practical example... I have two classes: User & Alert. When pushing User instances to the database (eg, creating new user accounts), there is a business rule that requires inserting some default Alerts records too (eg, a default 'welcome to the system' message etc). I see two options here: 1) Add this rule as a User method, and in the process create a dependency between User and Alert (or, at least, Alert's Table Data Gateway). 2) Use a Transaction Script, which avoids the dependency between models. (Also, means the business logic is kept in a 'neutral' class & easily accessible by Alert. That probably isn't too important here, though). User takes responsibility for it's own validation etc, however, but because we're talking about a business rule involving two Models, Transaction Script seems like a better choice to me. Anyone spot flaws with this approach?

    Read the article

  • The HTTP verb POST used to access path '/Documents/TestNote/Documents/AddNote' is not allowed.

    - by priya4
    I am having two user control on a aspx page and one of the user control has a text area for notes. and i am trying to use JSON so that when they click the addnote button it does not reload the page. Below is my java script , but it says that it is giving this error The HTTP verb POST used to access path '/Documents/TestNote/Documents/AddNote' is not allowed. <script type="text/javascript"> $(document).ready(function() { $("#btnAddNote").click(function() { alert("knock knock"); var gnote = getNotes(); //var notes = $("#txtNote").val(); if (gnote == null) { alert("Note is null"); return; } $.post("Documents/AddNote", gnote, function(data) { var msg = data.Msg; $("#resultMsg").html(msg); }); }); }); function getNotes() { alert("I am in getNotes function"); var notes = $("#txtNote").val(); if (notes == "") alert("notes is empty"); return (notes == "") ? null : { Note: notes }; } </script> My controller [HttpPost] public ActionResult AddNote(AdNote note) { string msg = string.Format("Note {0} added", note.Note); return Json(new AdNote { Note = msg }); }

    Read the article

  • Why are custom events not working for me? (Mootools)

    - by John McCollum
    I've been learning Mootools, but I'm having problems firing custom events. I'm sure it must be something simple, but I can't see it for the life of me. I wrote a simple class to nudge some list items using Fx.Tween. It works perfectly, except that the custom events aren't being triggered, no matter what I try. <script type="text/javascript"> var Pusher = new Class({ Implements: [Events,Options], options: { elements: [] }, initialize: function(options){ this.setOptions(options); this.attachListeners(this.options.elements); }, attachListeners: function(elements){ $$(elements).each(function(el){ $(el).addEvent('mouseover', this.pushIn.bind(el)) .addEvent('mouseout', this.pushOut.bind(el)); }, this); }, pushIn: function(){ this.fireEvent('in'); this.set('tween', {duration: 'short'}); this.tween('paddingLeft', '50px'); }, pushOut: function(){ this.fireEvent('out'); this.set('tween', {duration: 'short'}); this.tween('paddingLeft', '0px'); } }); window.addEvent('domready', function(){ var p = new Pusher({ elements: $$('li') }); p.addEvent('in', function(){ alert('in'); }); p.addEvent('out', function(){ alert('out'); }); }); </script> And in the HTML: <ul id="mylist"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> I've also tried the following: window.addEvent('domready', function(){ var p = new Pusher({ elements: $$('li'), onIn: function(){ alert('in'); }, onOut: function(){ alert('out'); } }); }); What am I doing wrong?

    Read the article

  • How to output JSON from within Django and call it with jQuery from a cross domain?

    - by Emre Sevinç
    For a bookmarklet project I'm trying to get JSON data using jQuery from my server (which is naturally on a different domain) running a Django powered system. According to jQuery docs: "As of jQuery 1.2, you can load JSON data located on another domain if you specify a JSONP callback, which can be done like so: "myurl?callback=?". jQuery automatically replaces the ? with the correct method name to call, calling your specified callback." And for example I can test it successfully in my Firebug console using the following snippet: $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any& format=json&jsoncallback=?", function(data){ alert(data.title); }); It prints the returned data in an alert window, e.g. 'Recent uploads tagged cat'. However when I try the similar code with my server I don't get anything at all: $.getJSON("http://mydjango.yafz.org/randomTest?jsoncallback=?", function(data){ alert(data.title); }); There are no alert windows and the Firebug status bar says "Transferring data from mydjango.yafz.org..." and keeps on waiting. On the server side I have this: def randomTest(request): somelist = ['title', 'This is a constant result'] encoded = json.dumps(somelist) response = HttpResponse(encoded, mimetype = "application/json") return response I also tried this without any success: def randomTest(request): if request.is_ajax() == True: req = {} req ['title'] = 'This is a constant result.' response = json.dumps(req) return HttpResponse(response, mimetype = "application/json") So to cut a long story short: what is the suggested method of returning a piece of data from within a Django view and retrieve it using jQuery in a cross domain fashion? What are my mistakes above?

    Read the article

  • Adding "Next Topic" and "Previous Topic" Buttons to 130 webpages, code not working unless alerted fi

    - by John Guise
    I have put "Next Topic" and "Previous Topic" ( fixed)on each web page so you can click to move one page back or forward through the web site. Here is the code: $(document).ready(function($){ $("#fixed").prepend(''); $("#fixed").prepend(''); $('#nt').css({'position':'relative','top':'0','left':'24px','font-size':'9px'}); $('#pt').css({'position':'relative','top':'0','left':'0','font-size':'9px'}); var fname = document.location.href; var thistopic = (fname).split('/').pop(); alert(thistopic); var nexttopic = $('#jsddm li a'); nexttopic.each(function(index) { var ref = $(this).attr('href'); if (ref == thistopic){ var num =(index) }else{ return; } var flnk =($(nexttopic)[num+1].getAttribute('href', 2)); var blnk =($(nexttopic)[num-1].getAttribute('href', 2)); $('#nt').live('click', function(){ location.href=flnk; }); $('#pt').live('click', function(){ location.href=blnk; }); }); }); id=nt is the "Next Topic" Button,id=pt is the "Previous Topic" Button flnk is the HREF of the next topic page, blnk is the HREF of the prvious topic page. HREFs are grabbed from - ul#jsddm li ul li a - a large unordered list menu. This code works correctly if I have the eighth line included "alert(nexttopic)" If I take this line out (which I want to, as I do not want alert box popping up) - then the code will not work. Can anybody put me right please, so the buttons work without "alert(nexttopic)" line included

    Read the article

  • show UIAlertView when In app purchase is in progress

    - by edie
    Hi... I've added an UIAlertView that has UIActivityIndicatior as a subview on my application. This alertView only show when the purchase is in progress. I've put my alert view in this way in my StoreObserver: - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchasing: [self stillPurchasing]; // this creates an alertView and shows break; case SKPaymentTransactionStatePurchased: [self completeTransaction:transaction]; break; case SKPaymentTransactionStateFailed: [self failedTransaction:transaction]; break; case SKPaymentTransactionStateRestored: [self restoreTransaction:transaction]; break; default: break; } } } - (void) stillPurchasing { UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"In App Purchase" message: @"Processing your purchase..." delegate: nil cancelButtonTitle: nil otherButtonTitles: nil]; self.alertView = alert; [alert release]; UIActivityIndicatorView *ind = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge]; self.indicator = ind; [ind release]; [self.indicator startAnimating]; [self.alertView addSubview: self.indicator]; [self.alertView show]; } When I tap my the buy button this UIAlertView shows together with my UIActivityIndicator.. But when the transaction completes the alertView still on the top of the view and the Indicator was the only one that was removed. My question was how should I release the alertView? Or where/When should I release it. I've added these command to release my alertView and Indicator on these cases: case SKPaymentTransactionStatePurchased: case SKPaymentTransactionStateFailed: case SKPaymentTransactionStateRestored: [self.indicator stopAnimating]; [self.indicator removeFromSuperview]; [self.alertView release]; [self.indicator release]; I've only added the alertView to show that the purchasing was still in progress. Any suggestion to create any feedback to users will be thankful for me.. Thanks

    Read the article

  • POSTing JSON data to WCF REST

    - by Randall Sexton
    I'm trying to send data from a client application using jQuery to a REST WCF service based on the WCF REST starter kit. Here's what I have so far. Service Definition: [WebHelp(Comment = "Save PropertyValues to the database")] [WebInvoke(Method = "POST", UriTemplate = "PropertyValues_Save", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [OperationContract] public bool PropertyValues_Save(Guid assetId, Dictionary<Guid, string> newValues) { ... } Call from the client: $.ajax({ url:SVC_PROPERTYVALUES_SAVE, type: "POST", contentType: "application/json; charset=utf-8", data: jsonData, dataType: "json", error: function(XMLHttpRequest, textStatus, errorThrown) { alert(textStatus + ' ' + errorThrown); }, success: function(data) { if (data) { alert('Values saved'); $("#confirmSubmit").dialog('close'); } else { alert('Values failed to save'); $("#confirmSubmit").dialog('close'); } } }); Example of the JSON being passed: { "assetId": "d70714c3-e403-4cc5-b8a9-9713d05b2ee0", "newValues": [ { "key": "bd01aa88-b48d-47c7-8d3f-eadf47a46680", "value": "0e9fdf34-2d12-4639-8d70-19b88e753ab1" }, { "key": "06e8eda2-a004-450e-90ab-64df357013cf", "value": "1d490aec-f40e-47d5-865c-07fe9624f955" } ] } I'm using Windows Authentication on the virtual directory. When I call operations that are GETs, everything is fine. This code is prompting the browser to log in. When I enter my credentials, I simply get an alert in my browser which says "error undefined". Even if you can't help my specific error, do you see anything that looks wrong from glancing? I've been beating my head on this nearly all day. Thanks in advance.

    Read the article

  • jQuery.post() issues with passing data to jQuery UI

    - by solefald
    Hello, I am trying to get jQuery.post() to run my php script and then open a jQuery UI dialog with the data that php script returns. Its supposed to come back as a form with a table and a textarea in it. It works great with alert(data); and i get a pop-up with all my data. The problem starts if i turn off alert(). Now it opens 2 dialogs. One containing only the table, without textarea, and the second one absolutely empty. What am i doing wrong here? How come all my data shows up in the alert(), but not in dialog? What do i need to do to fix it? Oh, and do i need to also include $.ajax() before the $.post()? Thank you. $.post("/path/to/script.php", { id: this.id, value: value }, function(data){ // THIS WORKS //alert(data); // THIS DOES NOT WORK $(data).dialog({ autoOpen: true, width: 400, modal: true, position: 'center', resizable: false, draggable: true, title: 'Pending Changes' }); } );

    Read the article

  • Javascript keyup doesn't work as expected, it executes in instances where I have not removed my fing

    - by Binni
    I'm trying to create a simple game in javascript and I'm stuck on how to deal with keys. Small example: function keyUpEvent(event) { alert(event.keyCode); } window.addEventListener("keyup", keyUpEvent, false); I'm running Ubuntu 9.10 and testing it in Firefox 3.5 and Chromium. If I press and release a button instantly I get an alert, which is to be expected, but when I press and hold a button I get a small pause and then a series of alert windows, the expected result is that I only get an alert window when I remove my finger from a button. I reason it has something to do with the fact that when I press and hold a button in a text area for example I get one character, small pause, and then a series of characters: dddddddddddddddd. I believe it's possible to get around this or do it more right or whatever since this game for example: http://bohuco.net/testing/gamequery/pong.html seams not to be affected by this. But I notice if I try out the jquery keyup demo ( api.jquery.com/keyup/ ) I get the same problem. How can I implement basic game key event handling?

    Read the article

  • Authorization and Jquery dialog problem.

    - by bbrepols
    Hi, I have a little problem with a Jquery dialog for an action that requires a role. In my example, the user can click on a delete button and must confirm the action. In my controller, the Delete action requires a role, if the user is in the required role, the object is deleted. The problem: How to alert the user if * the element was deleted (redirect to the Index view) * there was an error (alert with the message) * he doesn't have the rights to delete (alert with the message) Before using the authorize filter, the delete action returned a JSON with a Boolean that indicates if there was an error, an URL to redirect on success and a message to alert on error. As I can't return a JSON from my filter, I created an other method with the authorize filter that returns a partial view with the confirm content. If the user doesn't have the rights, the filter returns a partial view with an unauthorized exception content. The problem: How to distinct which partial view was returned. When I create the dialog, I need to know for the buttons function. Thanks!

    Read the article

  • AJAX Submit to PHP still loading page after preventDefault()

    - by dannyburrows
    I have a webpage that I am using .ajax to send variables to a php script. The php page is loading into the browser as if I was navigating to it. The script is loading the data correctly, so my issue is stopping the navigation and keeping the user on the original page. The code for my form is here: echo "<form method='post' action='addTask.php' id='myform'>\n"; echo "<input name='addtask' id='addtask' maxlength='64'/><br/>\n"; echo "<input type='submit' name='submit' id='submit' value='Add Task'/>\n"; echo "</form>\n"; The code for my jquery is here: $(function(){ $('#myform').submit(function(e){ e.stopPropagation(); $.ajax({ url: 'addTask.php', type: 'POST', data: {}, success: alert("Success") }); }); }); I have tried: e.preventDefault(), e.stopPropagation() and return false. Any help is appreciated. $("#submit").click(function(e){ e.preventDefault(); $.ajax({ type: "POST", url: "addtask.php", data: { } }) .done(function() { alert( "success" ); }) .fail(function() { alert( "error" ); }); and $(function(){ $('#myform').submit(function(e){ e.preventDefault(); $.ajax({ url: 'addTask.php', type: 'POST', data: {}, success: function(){alert("Success")} }); }); });

    Read the article

  • ZipArchive on the iPhone unzips files but they are empty

    - by user345131
    I'm trying to use ZipArchive on the iPhone to unzip a simple text file. It returns with no error but the file is empty. I would love to know why this doesn't work. I am using the following methods: -(void)alert:(NSString*)message { UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [myAlert show]; [myAlert release]; } -(void)unzip { NSString *sourcepath = [[NSBundle mainBundle] pathForResource:@"secret" ofType:@"zip"]; NSString*filename = @"secret.txt"; NSArray *docPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *destinationpath = [docPaths objectAtIndex: 0]; if (filename != nil ) destinationpath = [destinationpath stringByAppendingPathComponent: filename]; ZipArchive* za = [[ZipArchive alloc] init]; if( [za UnzipOpenFile:sourcepath Password:@""] ) { BOOL ret = [za UnzipFileTo:destinationpath overWrite:YES]; if( NO==ret ) [self alert:@"Problem"]; else [self alert:@"Success"]; [za UnzipCloseFile]; } [za release]; NSString *test = [[NSString alloc] initWithContentsOfFile:destinationpath encoding:NSASCIIStringEncoding error:nil]; [self alert:test]; }

    Read the article

  • Prevent Rails link_to_remote multiple submits w Javascript

    - by Chris
    In a Rails project I need to keep a link_to_remote from getting double-clicked. It looks like :before and :after are my only choices - they get prepended/appended to the onclick Ajax call, respectively. But if I try something like: :before => "self.stopObserving()" t,he Ajax is never run. If I try it for :after the Ajax is run but the link never stops observing. The solutions I've seen rely on creating a variable and blocking the whole form, but there are multiple link_to_remote rows on this page and it is valid to click more than one of them at a time - just not the same one twice. One variable per row declared outside of link_to_remote seems very kludgey... Instead of using Prototype I originally tried plain Javascript first for this proof of concept - but it fails too: <a href="#" onclick="self.onclick = function(){alert('foo');};"click</a just puts up an alert when clicked - the lambda here does nothing? This next one is more like the desired goal and should only alert the first time. But instead it alerts every time: <a href="#" onclick="alert('bar'); self.onclick = function(){return false;};"click</a All ideas appreciated!

    Read the article

  • ExtJs getting the FormPanel that is created dynmaically from button click.

    - by sharad
    I have Extjs ViewPort panel, that contain center panel, that contain tablpanel, in which I have added gridpanel in one tab, on this I have put 'Add Person' button in tbar of , that will add a new tab of a FormPanel, in its Reset button, I am not able to access Form to reset it. Do any body have faced same issue... please help how to get it working. Ext.onReady( function(){ // Ext.get(document.body, true).toggleClass('xtheme-gray'); var myBorderPanel = new Ext.Viewport({ title: 'Software Releases', // renderTo: document.body, renderTo: Ext.getBody(), layout: 'border', id: 'main', items: [ { title: 'Center Region', region: 'center', // center region is required, no width/height specified tbar: [ { text: 'Add person', // only when user have write priovilege. handler: function() { var tabpanel = Ext.getCmp('main').findById('tabs'); var wtab = tabpanel.add({ // // var addrelease_win = new Ext.Window({ url: 'reledit-submit.json', id: 'addform0', // height: 300, width: 400, layout: 'form', frame: true, title: 'Add New Release', closable: true, items: [ { xtype: 'textfield', fieldLabel: 'Name' } buttons: [{ text: 'Save', scope: wtab, handler: function() { wtab.getForm().submit({ success: function(f,a) { Ext.Msg.alert('Success', 'It worked'); }, failure: function(f,a){ Ext.msg.alert('Warnning', 'Error'); } }); } },{ text: 'Reset', scope: wtab, handler: function() { // Ext.getCmp('addform0').getForm().reset(); // tabpanel.getActiveTab.reset(); // Ext.getCmp('main').findById('addform').getForm().reset(); // this.getForm().reset(); // this.getForm().reset(); // Ext.Msg.alert('sdfsd', 'asdfsd ' + Ext.getCmp('addform0').getValue() + ' sdfsd'); this.findById('addform0').getForm().reset(); // Ext.Msg.alert('sdfsd', 'asdfsd '); } }] }); // addrelease_win.show(); tabpanel.activate(tabpanel.items.length - 1); } } ], xtype: 'tabpanel', id: 'tabs', activeTab: 0, items: [{ title: 'Data', xtype: 'editorgrid', store: store, stripeRows: true, // autoExpandColumn: 'title', columns: [ {header: "Name" , dataIndex: "name" , width: 50, sortable: true}, {header: "DOB", dataIndex: "dob" , sortable: true} ], }) }], margins: '5 5 0 0' } ] }); }

    Read the article

  • Setting javascript prototype function within object class declaration

    - by Tauren
    Normally, I've seen prototype functions declared outside the class definition, like this: function Container(param) { this.member = param; } Container.prototype.stamp = function (string) { return this.member + string; } var container1 = new Container('A'); alert(container1.member); alert(container1.stamp('X')); This code produces two alerts with the values "A" and "AX". I'd like to define the prototype function INSIDE of the class definition. Is there anything wrong with doing something like this? function Container(param) { this.member = param; if (!Container.prototype.stamp) { Container.prototype.stamp = function() { return this.member + string; } } } I was trying this so that I could access a private variable in the class. But I've discovered that if my prototype function references a private var, the value of the private var is always the value that was used when the prototype function was INITIALLY created, not the value in the object instance: Container = function(param) { this.member = param; var privateVar = param; if (!Container.prototype.stamp) { Container.prototype.stamp = function(string) { return privateVar + this.member + string; } } } var container1 = new Container('A'); var container2 = new Container('B'); alert(container1.stamp('X')); alert(container2.stamp('X')); This code produces two alerts with the values "AAX" and "ABX". I was hoping the output would be "AAX" and "BBX". I'm curious why this doesn't work, and if there is some other pattern that I could use instead.

    Read the article

  • Why does this attempt at preloading images with jQuery not work?

    - by Eric
    Current I have this code: var imgCount = 36; var container = $('#3D-spin'); var loaded = 0; function onLoad() { alert(loaded); loaded++; if(loaded >= imgCount) { alert('yay'); } } for(var i = imgCount-1; i >= 0; i--) { container.prepend( $('<img>') .one('load', onLoad) .attr('alt', 'View from '+(i*360/imgCount)+'\u00B0') .attr('src', '/images/3d-spin/robot ('+i+').jpg') ); } However, it's behaving VERY strangely. Normally, I get no alert boxes. However, if I open developer tools, and pause script execution, I get a single alert that says 0. There's nothign like a good old heisenbug! A live example can be found here. The script itself is called style.js, and it is clear that images have loaded. Am I doing something stupidly, or is jQuery playing up?

    Read the article

  • After travelling back in Firefox history, javascript won't run.

    - by Patonza
    When I use the back button on Firefox to reach a previously visited page, scripts on that page won't run again. Is there any fix/workaround to have the scripts execute again when viewing the page the second time? Please note that I have tested the same pages on Google Chrome and Internet Explorer and they work as intended. Here are the files and the steps I used to test the problem: (navigate to 0.html, click to get to 1.html, back button) 0.html <html><body> <script type="text/javascript"> window.onload = function() { alert('window.onload alert'); }; alert('inline alert'); </script> <a href="1.html">Click Me!</a> </body></html> 1.html <html><body> <p>Go BACK!</p> </body></html>

    Read the article

  • The Classic jQuery Tabs with Bing Maps Issue

    - by Justin
    Hello, I know that there are multiple issues with jQuery Tabs and using Maps. And I have seen the multiple fixes and I am half-way there. But I have the most obscure issue and hoping that someone might understand why. This is my code for the tabs $("#contactTabs").tabs({ spinner: 'Loading <img src="../images/icons/ajax-loader.gif" />' }); $('#contactTabs').bind('tabsshow', function(event, ui) { if (ui.panel.id == "Map") { GetMap(); } }); Which currently does not work. But I was doing some testing and added in an ALERT() to see if the "GetMap()" was even attempting to be loaded... so this was the code that I tested with, and it works just fine. $("#contactTabs").tabs({ spinner: 'Loading <img src="../images/icons/ajax-loader.gif" />' }); $('#contactTabs').bind('tabsshow', function(event, ui) { if (ui.panel.id == "Map") { alert("load map"); GetMap(); } }); So I haven't a clue why adding the ALERT() causes the map to load and removing the ALERT just doesn't load the map at all. Is there any clarification that someone can give me on this issue? Thank you in advance!

    Read the article

  • JavaScript function, which reads connections between objects

    - by Nikita Sumeiko
    I have a JavaScript literal: var members = { "mother": { "name" : "Mary", "age" : "48", "connection": { "brother" : "sun" } }, "father": { "name" : "Bill", "age" : "50" }, "brother": { "name" : "Alex", "age" : "28" } } Than I have a function, which should read connections from the literal above. It looks like this: function findRelations(members){ var wires = new Array(); var count = 0; for (n = 0; n < members.length; n++){ alert(members.length); // this alert is undefined if (members[n].connection){ for (i = 0; i < members[n].connection[0].length; i++){ var mw = new Array(); var destination = 0; for (m = 0; m < members.length; m ++){ if (members[m] == members[n].connection[0]){ destination = m; mw = [n, destination]; wires [count] = mw; count++; } } } } } return wires; } However, when I run this function, I get nothing. And the first alert, which is placed inside the function shows 'undefined' at all. findRelations(members); alert("Found " + wires.length + " connections"); I guess that's because of JavaScript literal. Could you suggest how to change a function or perhaps to change litteral to JSON array to get it work?! And at the end to get 'm' and 'n' values as numbers.

    Read the article

  • html select execute javascript onload

    - by portoalet
    I am using HTML select onchange event to fire another javascript function func1. This html select is written into a form element, which are dynamically generated when users click on a button. The problem is how can I fire the javascript func1 when the dynamically generated form is first shown ? I am thinking of something along the line of on_first_show event for form ? Here is the snippet. I couldnt get the alert('don') to work either (the one just after div) var sPopupContents = "<div ><script type='text/javascript'>alert('don');</script> </div>"; // this javascript is not executed ? I cant get the alert. sPopupContents += "<form name='theform' >"; sPopupContents += "<select name='theselect' onchange='alert(2);"; sPopupContents += "func1()>'"; sPopupContents += "<option value='0' selected='selected'>Value1</option><option value='1'>Value2</option><br/>"; sPopupContents += "</form>";

    Read the article

  • Dynamically adding radio buttons using JQUERY and then hooking up the jquery change event to the gen

    - by Barry
    i am adding collection of radio buttons to my page using jquery below $(document).ready(function() { $("#Search").click(function() { var keyword = $('#keyWord').val(); var EntityType = $("#lstEntityTypes :selected").text(); var postData = { type: EntityType, keyWord: keyword }; // alert(postData.VehicleType); $.post('/EntityLink/GetJsonEntitySearchResults', postData, function(GRdata) { var grid = '<table><tr><td>ID</td><td>Name</td><td></td>'; for (var i = 0; i < GRdata.length; i++) { grid += '<tr><td>'; grid += GRdata[i].ID; grid += '</td><td>'; grid += GRdata[i].EntityName; grid += '</td><td>'; grid += '<input type="radio" name="EntitiesRadio" value="' + GRdata[i].ID + '" />'; grid += '</td></tr>'; } grid += '</table>'; alert(grid); $("#EntitySearchResults").html(grid); $("EntitiesRadio").change(function() { alert($("EntitiesRadio :checked").val()); $("EntityID").val($("EntitiesRadio :checked").val()); alert($("EntityID").val()); $("EntityName").val($("#lstEntityTypes :selected").text()); }); }); }); // }); so when page loads there is not EntitiesRadio name range, so i tried to register the entitiesRadio change function inside the same search click method but it isnt registering. how do i get the change event to fire to update my hidden inputs

    Read the article

  • AjaxFileUpload return download panel when data is json

    - by Tr.Crab
    I use AjaxFileUpload (http://www.phpletter.com/Our-Projects/AjaxFileUpload/ ) to upload a file and get json result type response in struts2 ( code.google.struts2jsonresult.JSONResult ) but browser always pop-up download pane, plz give me some suggestions, thanks in advance Here is my config in struts.xml : ...... <result-type name="json" class="code.google.struts2jsonresult.JSONResult"> ............ <action name="doGetList" method="doGetList" class="main.java.GetListAction"> <result type="json"> <param name="target">jsonObject</param> <param name="deepSerialize">true</param> <param name="patterns"> -*.class</param> </result> </action> and js client : function ajaxFileUpload(){ $("#loading").ajaxStart(function(){ $(this).show(); }).ajaxComplete(function(){ $(this).hide(); }); $.ajaxFileUpload ( { url:'doGetList.do', secureuri:false, fileElementId:'uploadfile', dataType: 'json', success: function (data, status) { if(typeof(data.error) != 'undefined') { if(data.error != '') { alert(data.error); } else { alert(data.msg); } } }, error: function (data, status, e) { alert(e); alert(data.records); } } ) return false; }

    Read the article

  • Issue on dojo onlick event on html button

    - by Cuong Le
    I am a new kid with dojo, I got weird issue which I take lots of time and have not yet found out, assume I have 4 buttons: <button id="btnMoveFirst" data-dojo-type="dijit.form.Button" iconclass="plusIcon"> &lt; &lt;</button> <button id="btnMovePrev" data-dojo-type="dijit.form.Button" iconclass="plusIcon"> &lt;</button> <button id="btnMoveNext" data-dojo-type="dijit.form.Button" iconclass="plusIcon"> &gt;</button> <button id="btnMoveLast" data-dojo-type="dijit.form.Button" iconclass="plusIcon"> &gt; &gt;</button> And use dojo with event onclick as below: dojo.connect(dijit.registry.byId('btnMoveFirst'), "onclick", function(evt){ alert('test1'); }); dojo.connect(dijit.registry.byId('btnMovePrev'), "onclick", function(evt){ alert('test2'); }); dojo.connect(dijit.registry.byId('btnMoveNext'), "onclick", function(evt){ alert('test3'); }); dojo.connect(dijit.registry.byId('btnMoveLast'), "onclick", function(evt){ alert('test4'); }); But when I click any one of 4 buttons, or even any button in form, I got 4 alerts instead of only correct one. Does anyone know this?

    Read the article

  • Count the no of LI then add class to parent UL.

    - by Wazdesign
    <ul class="taglib-ratings thumbs"> <li id="qezr_yourRating"> <a href="javascript:;" class="rating rate-up "></a> </li> </ul> <ul class="taglib-ratings thumbs"> <li id="qezr_yourRating"> <a href="javascript:;" class="rating rate-up "></a> </li> <li id="qezr_yourRating"> <a href="javascript:;" class="rating rate-up "></a> </li> </ul> I want to apply the class to the UL on base of the Count of the Inner LIs. Like if it has two LI then the class should be like two-thumbs Like if it has one LI then the class should be like one-thumbs I am trying this JS but not working it returns 2 jQuery(document).ready(function(){ var countLi = $(".taglib-ratings > li").size(); alert(countLi); if(countLi == 2) { $(this).parent('.taglib-ratings').addClass('2-col'); alert ('this ul has 2 li'); } else if(countLi == 1) { $(this).parent('.taglib-ratings').addClass('2-col'); alert ('this ul has 1 li'); } else if(countLi > 2) { alert ('this ul has'+ countLi +' li'); } }); Here is the JSbin link to the same. http://jsbin.com/ofeda/edit

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >