Menu
  • HOME
  • TAGS

Regular expression that match a text if it contains a string ONLY once

regex,string,once

To check if text contains some substring only once, you need to check match all characters that do not constitute <scr>, then match <scr>, and use a negative look-ahead to check if there is no <scr> further, and consume all characters. Also, line/string boundaries ^/$ are a must: ^(?:(?!<scr>).)*<scr>(?!.*<scr>).*$ See...

jQuery: Eventhandler works only once

jquery,event-handling,click,once

The problem is, that slider.reloadSlider({ startSlide: currentSlide }); recreates the slider elements. Which breaks the click event handler, since the original button gets replaced. You could change it to .on() and it should work. For example. $('body').on('click','a.bx-next',function() { console.log("Clicked 'next'"); // that happens only once!! steps++; if(steps % 1 ==...

Making Pygame Play Sound ONCE

python,loops,audio,pygame,once

I guess it's played over and over again because the condition of the if clause stays True; and probably it's True for multiple block objects in block_list. You should fix that in a way that makes sense for your application. It's hard to give a good advice when you don't...

jQuery append only once

jquery,append,once

just use a boolean, jQuery("document").ready(function($){ var nav = $('#nav'); var logo = '<img id="lilLogo" src="img/logo.png" />'; var visible = false; $(window).scroll(function () { if ($(this).scrollTop() > 136) { nav.addClass("nav-f"); if(!visible) { nav.append(logo); visible = true; } } else { nav.removeClass("nav-f"); if(visible) { $('#lilLogo').remove(); visible = false; } } }); });...

Camel consume single message and stop, transacted

java,transactions,apache-camel,consumer,once

I ended up using the pollEnrich dsl to achieve this. For example my route builder looks like: from("direct:service-endpont").transacted("PROPOGATION_REQUIRED").setExchangePattern(ExchangePattern.InOut).pollEnrich("activemq:test-queue").bean(myHandler); I use the direct endpoint as a service, sending a "request" message to the direct endpoint polls the jms queue for a single message (blocking if required). The transaction started extends to...

Set cookie to show div only once per session

cookies,once

You may take a look at the documentation of the document.cookie and more specifically example 3: if (document.cookie.replace(/(?:(?:^|.*;\s*)someCookieName\s*\=\s*([^;]*).*$)|^.*$/, "$1") !== "true") { alert("Do something here!"); document.cookie = "someCookieName=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"; } In this example the cookie is created with expires flag meaning that it will...

jquery autoplay function works only once

javascript,jquery,once

remove the single quotes for the setTimeout function function the first argument be function not a string. sliderTimeout = setTimeout(sliderAutoplay, 3000 ); ...

loading of javascript function only once using .one() API

jquery,api,once

This works use instead of "load" to "ready" not sure why its not working with the load $(document).one('ready',function(){ // Perform something here... alert("ther you go"); }); Keep in mind that "ready" fires before "load"....

How do I make this function work for a single time for my html page?

javascript,jquery,html,function,once

try this.. $('.show-popup').hover(function(event){ event.preventDefault(); // disable normal link function so that it doesn't refresh the page var docHeight = $(document).height(); //grab the height of the page var scrollTop = $(window).scrollTop(); //grab the px value from the top of the page to where >you're scrolling var selectedPopup = $(this).data('showpopup'); //get the...

How to get unique id of lambda function for “do once” pattern?

c#,lambda,anonymous-function,uniqueidentifier,once

I just discovered elegant and simple solution: using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Runtime.CompilerServices; public class Once : IDisposable { HashSet<Tuple<string,int>> passed; public Once(){ passed = passed.New(); } public bool Do(Expression<Action> act, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0 ){ if(act != null){ var id =...

Click function, inside .off removed handler, want it back

jquery,click,handler,once

Try This $( function() { $('div').click(function() { if (!$(this).hasClass('active')) $(this).addClass('active'); }); // x pressed $('body').on('click','div.active span', function() { $(this).parent().removeClass('active'); }); }); DEMO HERE...

jquery prevent function running more than once

jquery,function,once

Try utilizing $.Callbacks("once") var callbacks = $.Callbacks("once"); callbacks.add(mySepsisTimer); $('#sepsis-six-sirs input[type=checkbox]').change(function() { recalculateThisIsSepsis(); }); function recalculateThisIsSepsis(){ var sum = 0; $("#sepsis-six-sirs input[type=checkbox]:checked").each(function() { sum+=parseInt($(this).val()); }); if (sum > 1) { callbacks.fire(); } } ...