w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
jquery function called twice
try .on() instead of bind and look for manual triggers. Also a stop propagation maybe? Why applying on window instead of document? You can also add a debugger command : $(window).on( 'hashchange', function(e) { debugger; e.stopPropagation(); [...] });

Categories : Javascript

Why is my jQuery function not being called correctly?
You can make a button that would be calling your function: <button onclick="validateNewQuiz()">Submit</button> ... and submitting the form once it is validated: function validateNewQuiz() { CSV.begin("#upload_csv").go(function(e,D) { //... if(/^(([^,]+,){4}[^,]+ ){3}$/.test(fullString)) { $("form").submit(); } }); return false; }

Categories : Javascript

unbinding a function after called once in jquery
For what you're asking deleting a global property and specifically the link given there: http://perfectionkills.com/understanding-delete/ will help you understand why what you want is not possible (or really akward, you need to read the linked text for the full story). That makes me agree with @FabrícioMatté - you really, really want to rework your navigation function to keep track of what it loaded so you can just call it again and have it work out where to go next. There's no reason I can think of to redefine the function.

Categories : Jquery

Why does my second jQuery anonymous function not run when called?
The problem is that you're binding your handlers only to the elements that have the specified classes when the page is first loaded. If an element's class changes, the bindings don't automatically follow it. To solve this, use delegation with .on(). $(document).ready(function() { $(document).on('click', 'a.upvote-off', function() { $(this).removeClass('upvote-off').addClass('upvote-on'); }); $(document).on('click', 'a.upvote-on', function() { $(this).removeClass('upvote-on').addClass('upvote-off'); }); }); If there's a smaller DIV that encloses all the upvote elements, replace document with that ID to minimize the overhead of this.

Categories : Jquery

jsonp callback function not getting called with jQuery
A JSONP response is actually a script response - something like: callbackFunctionName([{'testing': 'testing'}, {'one': 1, 'two': 2, 'three': 3}]); Create a template that returns a application/javascript response with a function call to function request.GET.get('callback') with the body of the JSON as the only argument. Something like: def return_jsonp(request, json_data) return render_to_response("jsonp_template.html", Context({ 'callback': request.GET.get('callback'), 'json': json.dumps(json_data), }, mimetype="application/javascript") Where jsonp_template.html is just: {{ callback }}({{ json }});

Categories : Javascript

The (window).unload function is never being called in jQuery
This is by design. You simply can't alert() from the unload event: UI interactions are ineffective (window.open, alert, confirm etc.) If you're wanting to give the user a chance to change their minds about closing the window, beforeunload is the correct event. But, you can only return the message you want to display: window.onbeforeunload = function () { return 'Leaving already?'; };

Categories : Javascript

jQuery function cannot be called without an alert present
In your click functions add an event parameter And try adding this to the first line of your function - event.preventDefault(); So for example $(".judith_toggle_box").click(function(event) { event.preventDefault(); pageClicked = '.judith_toggle_box'; escClicked = !escClicked; $('.judith_close').toggleClass("judith"); }); EDIT: Forgot to add the event as a function parameter, please check again

Categories : Jquery

jQuery .click() function called automatically
You must pass a function reference to the .click() function, not the result of calling a function. When you include the () like this keepBothFiles(...) at the end of the function name, you are telling javascript to execute the function now. When you just use the name of the function like keepBothFiles, you are getting a reference to the function (which can be called later). You are currently calling your function immediately and then passing the return value of that function (which is not a function reference) to the .click() function, thus it does not do what you want. The click handler callback function is passed exactly one parameter (the event) in jQuery so you cannot have it call your keepBothFiles(file, progress, audioSrc) function directly like you have it. Instead, it could be

Categories : Javascript

Why is my jQuery/Javascript function not being called correctly with onsubmit?
html5csv puts a event handler on the file input so it only triggers when a file is added so you need to set a valid flag somewhere and then check it before submitting function checkValidCSV(e) { var isValid = jQuery("#form-step2").data("hasValidData"); if( typeof(isValid) != "undefined" && isValid ) { jQuery("#form-step2").submit(); } else { //Do whatever invalid data cals you want to do here alert("csv file was invalide so i am not submitting the form"); e.preventDefault(); } } function csvFileLoaded(e,D) { if (e) { return console.log(e); alert("Sorry, an error occured"); } var s = ""; for (var i = 0; i <= D.rows.length - 1; i++) { s +=D.rows[i].join(','); s += " "; } var

Categories : Javascript

jQuery function is not called when script src is added to head
Your include jQuery like three times in this code. i'm not sure if thats the problem but it ain't the solution // jquery from jquery.com <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <!-- jQuery (required) --> // jQuery from google <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="../js/jquery.min.js"></script>')</script> // both of these are expendable this might cause a conflict since the last one to be included is an older version of the library. you only need only inclusion. I'm assuming your using migrate because you have older jQue

Categories : PHP

obtain url paramethers from a page called with JQuery's load() function
You could use something like this to parse the URI: http://blog.stevenlevithan.com/archives/parseuri Then you can access the parameters easily from the parent page: // Set the link that we want to load/examine var link = 'page?foo=bar'; // Load the link content (as per your code) div.load(link); // Grab whatever variables we want from the link var uri = parseUri(link); var foo = uri.queryKey.hasOwnProperty('foo') ? uri.queryKey.foo : false; alert(foo); EDIT: As bfavaretto already commented, the content loaded in via AJAX is just a string. It's not a page that will be aware of its URI. However, if you really want the loaded content to be able to access its URI, just make it available in the content itself. For example: $('#my_div').load('page?foo=bar) And in the content of "page?

Categories : Javascript

this is bound incorrectly if jquery function is called from a stored variable
Yes it does not know the element it is applying fadeOut animation to and this context will be mostly the window and not the jquery object in this case. You can pass the context using function.call Try this: var fadeOutFn = $('#my-div').fadeOut; fadeOutFn.call($('#my-div')); Or just do this: use function.bind to bind the context to the function reference, and invoke it. var fadeOutFn = $().fadeOut.bind($('#my-div')); fadeOutFn(); Read function.bind For non supported browsers you can add this in your js file for support as mentioned in the document: if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { // closest thing possible to the ECMAScript 5 internal IsCallable function throw new TypeError("Function.pr

Categories : Javascript

Member function called PlaySound() causes linker error when called
My assumption based on the type of error you're getting and the fact that your function is in a separate namespace is that there is the following snippet somewhere (probably in a microsoft include): #ifdef _UNICODE #define PlaySound PlaySoundW #else #define PlaySound PlaySoundA #endif // _UNICODE These types of #define statements are common in microsoft's internal headers because they are designed to handle both unicode and multibyte character encodings. In order to get around this issue, you might want to put the following before you use your code: #undef PlaySound

Categories : C++

alert() called on new window seems to be called from opener page if using jquery's methods
Seems like this is the way jQuery handles <script> tag. domManip function in jQuery source code: // Evaluate executable scripts on first document insertion for ( i = 0; i < hasScripts; i++ ) { node = scripts[ i ]; if ( rscriptType.test( node.type || "" ) && !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { if ( node.src ) { // Hope ajax is available... jQuery._evalUrl( node.src ); } else { jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); } } } domManip will strip all the <script> elements, evaluate them in global context and then disable. domManip is called by append() method: append: function(

Categories : Javascript

.click function not working when the event is called by element created by another function
For dynamically created elements ,You have to do event delegation $(document).on("click", ".cancel" , function(event){ alert($(this).text()); });

Categories : Javascript

ajax search function called twice using $(window).bind( 'hashchange', function(e)
maybe I don't understand well, but why did you bind hashchange function to window??? It doesn't make any sence. I have similar searching function in my own apps. It is not that complicated. My search function is (lets say) same as yours: function search_ajax(sh_val,sh_act) { ....some search code..... window.location.hash = sh_val+'@'+sh_act; } The another one is performed once per page load: (function() { var page=location.hash.slice(1) if (page!="" && page!="p") { search_ajax(page,'catsh'); } return false; })(); So, if you click search button, then search function is called. Hash is changed. One step into browser history is added. Then another search, another step in history is added. Then back button. Page loaded again, so annonymous function

Categories : Javascript

How to execute the function return the value to called function across node js files
Unable to send the variable resourceIdentifiers from subscriptionRestService to mysqlRestService.js Well, you didn't send it. It currently is a parameter of your callback function in the invocation, not an argument for the parameter of getPricingDetails. Use mysql.getPricingDetail(resourceIdentifiers, function callback(result){ // use result here }); Unable to return the pricingdetail from mysqlRestService.js to calling function in subscriptionRestService. I've got no idea what pricingDetail = pricingDetail; was supposed to do. You have to call (invoke) back the callback here! Use callback(pricingDetail);

Categories : Javascript

Javascript function not working when the event is called by element from another function
Change your function to: function showElement() { $('#mydiv').html("<input class='datepicker' />"); $( ".datepicker" ).datepicker(); } Or even better, do the following: function showDatePicker(selector) { $(selector).datepicker(); } function showElement() { $('#mydiv').html("<input class='datepicker' />"); showDatePicker(".datepicker"); } This way you can show the date picker whenever you want by calling the showDatePicker() function for any element that matches the selector you pass as a parameter to the function. Of course in your case you would only want to call it after you have called the showElement() function

Categories : Javascript

Which one is called when existing an extern function with the same name as an inline function?
Your program has UB (Undefined Behaviour), because it violates ODR (One Definition Rule) by providing two different definitions of f(). There is therefore next to no way of reasoning why it behaves one way or the other. In the best tradition of UB, any behaviour is possible (including ordering pizza over the Internet). EDIT These quotes from the standard (ISO/IEC 14882:2011) prove it's UB: [basic.def.odr]§3: Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program; no diagnostic required. ... An inline function shall be defined in every translation unit in which it is odr-used. [basic.def.odr]§5: There can be more than one definition of ... inline function with external linkage ... in a program provided th

Categories : C++

Store a function variable's value to use it again next time function is called
Set an attribute for the last highlighted element: self.highlightRow = row You could set the attribute to None in your class's __init__. It is then just a matter of reading that attribute and un-highlighting that row.

Categories : Python

Adding a variable outside a function each time the function is called
var time=0; function computetime(result) { var mytravelroute=result.routes[0]; for (i = 0; i < mytravelroute.legs.length; i++) { time += mytravelroute.legs[i].duration.value; } var totalSec = time;

Categories : Javascript

Why is google chart function not being called when it's inside a function?
Here's something to start over from. function GoogleChart() { this.chart_data = ['3',7]; this.data_table = google.visualization.arrayToDataTable([['Scoring Activity', 'Points given'], chart_data]); this.options = { title: 'Semis overall scoring activity' }; this.chart = new google.visualization.PieChart(document.getElementById('chart_div')); } GoogleChart.prototype.drawChartDaily = function () { this.chart.draw(this.data_table, this.options); }; $(function () { function myOnLoadCallback() { var googleChart = new GoogleChart(); $('#menu_tab1').click(function(){ googleChart.drawChartDaily(); }); } google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(myOnLoadCallback)

Categories : Javascript

How do I pass a function with arguments to another function to be called?
A third argument might be simplest. If you don't want to use that, one possibility is to pass a function of one argument that then invokes the two-argument action method. forEachIn( objectList, function(equipment) { initEquipAnimations(equipment, animations); } ); This creates a closure assuming that animations is set to the animations to be used. Note that if animations might vary during the iteration, you might need to create another closure to capture the value using an IIFE: forEachIn( objectList, (function(anims) { return function(equipment) { initEquipAnimations(equipment, anims); } }(animations)) ); Another possibility is, if you have the flexibility of reordering the arguments to initEquipAnimation, is to bind the function to the leading arguments,

Categories : Javascript

Is it possible to modify a function itself when its property function is called?
Easily. Here's an example: var derp = 123; someFunction = function() {alert(derp);}; someFunction.somePropertyFunction = function() {derp = 456;}; someFunction(); // alerts 123 someFunction.somePropertyFunction(); someFunction(); // alerts 456 Okay, that's an oversimplified example, but yeah, it's entirely possible.

Categories : Javascript

How to test that a function is called within a function with nosetests
You can mock the function b using mock module and check if it was called. Here's an example: import unittest from mock import patch def a(n): if n > 10: b() def b(): print "test" class MyTestCase(unittest.TestCase): @patch('__main__.b') def test_b_called(self, mock): a(11) self.assertTrue(mock.called) @patch('__main__.b') def test_b_not_called(self, mock): a(10) self.assertFalse(mock.called) if __name__ == "__main__": unittest.main() Also see: Assert that a method was called in a Python unit test Mocking a class: Mock() or patch()? Hope that helps.

Categories : Python

jQuery errors "x.ready.promise is not a function" and "Modernizr.prefixed is not a function" / jQuery.noConflict
replace $ with jQuery if you have small amout of scripts.. or wrap them in: (function ($, window, document) { //code }(jQuery, window, document)); or jQuery(document).ready(function() { //code }); or (function(window, undefined) { 'use strict'; //code })(this);

Categories : Jquery

A function is called twice in VB.NET
My immediate reaction is a sticky mouse button, but really it's likely due to the web page you are loading having multiple pages being loaded, thus adding the duplicate event handler. Put a breakpoint on this line of code: AddHandler Document.Click, New HtmlElementEventHandler(AddressOf Document_Click) You'll likely see it being hit twice. Make sure to only wire up one HtmlElementEventHandler to avoid the double firing of the click event handler. You can check e.Url for a match before wiring up as a possible solution.

Categories : Vb.Net

Function gets called twice
Add this e.stopPropagation(). $('div').on('click', '[id^=network_picker]', function (e) { e.stopPropagation(); alert("YOU CLICKED IT!") }); And you seriously should use better ids. No commas or spaces and they should be unique!

Categories : Jquery

the second function not being called
You have defined a function named limit_char_unicode and it is not called from anywhere. $("#unicode").click(function() { $('#infodiv2').show(); $('#infodiv').hide(); $('#normal_message').val(''); $('#normal_message').bind('keyup keydown click',function(){ limit_char_normal('normal_message', 63, 'infodiv2'); }); }); Change limit_char_normal to limit_char_unicode in the above function and try.

Categories : Javascript

Getting the filename of where a function was called from
Thats a job for debug_backtrace(): function test($param) { echo "$param"; var_dump(debug_backtrace()); }

Categories : PHP

Why can't I use $app in called function for Slim?
the use keyword only applies to closure constructs, apart from the use with namespaces. so what your doing with a regular function is not supported. you will have to use global $app which is usually considered bad practice.

Categories : PHP

javascript function gets called twice
1. You do not need to use the qualifier 'javascript:' 2. when you hook the event in html, always try to do it like event_handler(event). Note : event is the event object. and not some random variable here. You can read more about it in numerous places on the web. In your case varthis is the event object. to access this element use varthis.target and then to get its inner html you can use varthis.target.innerHTML 3. when the function is called you have to either explicitly get the html content of the calling element via the event tag, or just use jquery. You cannot pass variables in the way you think you are passing right now. 4. if you are actually trying to submit a form, I would recommend hooking the onSubmit event in script rather than HTML and put your custom form submit code there.

Categories : Javascript

JS - called method is not a function
Like @Bergi said, it's a this value issue that can be solved by doing: window.onload = function () { devark.init(); }; The difference between both ways is the value of this within the init function. To determine the natural value of this, look at the left-side of the . in a method call, such as obj.someFn();. Here the value of this within someFn will be obj. However, when you do window.onload = devark.init;, you can imagine the handler will later be invoke like window.onload(). Which means the value of this within the onload function, which is really the init function will be window, not devark. You can also use Function.prototype.bind to bind a specific this value to a function. window.onload = devark.init.bind(devark);

Categories : Javascript

ASP.NET custom function is not called
Try redefining the handler. Remove OnServerValidate="CheckDOB" from Custom ASPX validator markup and define handler in VB like this: Protected Sub CheckDOB(ByVal source As Object, ByVal args As ServerValidateEventArgs) Handles CustomValidator1.ServerValidate End Sub

Categories : Asp Net

php function cannot be called for the second time
Really you should show errors and warnings whilst developing code. it would tell you what the problem is. E_ERROR : type 1 -- Cannot redeclare nested_clean() (previously declared in main/code_145461.php:5) -- at line 5 You are redeclaring the function by nesting the function definition inside the other function. I am not sure why you would nest your functions like this. try function htmlFilter_array(&$html_array) { array_walk_recursive($html_array, 'nested_clean'); } function nested_clean(&$value) { $value = htmlentities($value, ENT_QUOTES, "UTF-8"); }

Categories : PHP

function not called with the same name as a class
The inner i is shadowing the outer one. You are calling the default constructor of class i which does nothing in this case. The solution is to explicitly scope the call, as ::i();

Categories : C++

Php while only return 1 if called as function
Because you're returning in the middle of a while statement. It will break out of the WHILE() on the first iteration and return the FIRST result. You should try something like this: function get_players($aid) { $query = query("SELECT name FROM player WHERE account_id = $aid"); $names = array(); while ($row = fetch_assoc($query)) { $names[] = $row['name']; } } print_r( get_characters(1337) ); PS: You should not be using mysql_* functions. At the very least, learn MySQLI or PDO.

Categories : PHP

renderCell function not being called?
I have just run through the dgrid tutorial explaining how to use stores with your grid and I tested you render cell function by replacing all the columns with just your example, but obviously chose a field name included in the json they use. It worked a treat. Take a look at the example I referred to, it may help, it does not include renderCell, but it is a good starting point. To display some value from the data in the returned div I could just pick out the value argument to display in the returned html like so... function testRenderCell(object, value, node, options){ var div = document.createElement("div"); div.className = "renderedCell"; div.innerHTML = value; return div; } Here is the code snippet from my own index file, the data I used was just a local version of t

Categories : Javascript

Why the following function is called thrice
Because you tell it so: MAX(x, increment()) evaluates to ( (x) > (increment()) ? (x) : (increment()) ) and if the condition is not fulfilled, the part after the : is evaluated and thus the function called again.

Categories : C

Detoured function not being called
I dont see detourTransactionBegin(), DetourUpdateThread() and DetourTransactioncommit() calls here. API Hooking with MS Detours have a good explaination.

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.