FAQ Database Discussion Community


How to get an entry.bind and a button do the same thing?

python,button,tkinter,bind,entry
I think the name of the topic is pretty clear, I haven't found any answer elsewhere so I came to ask for it. I have a tkinter GUI with an entry and a validation button. I'd like to call the same function when I press a key in the entry,...

PDO SQL injection (fetching variable from url)

mysql,pdo,bind
I have an id that is passed in the URL (e.g. id=33). It is always a number. I used to use the standard mysql to connect and use escape string and int to make secure etc. I'm trying to move onto PDO and I think the code below is secure...

jQuery off() is not unbinding events when using bind

javascript,jquery,javascript-events,bind,jquery-events
function bubble(content, triggerElm){ this.element = $('<div class="bubble" />').html(content); this.element.css(.....) // here is positioned based on triggerElm } bubble.prototype.show = function(){ $(document).on('click', this._click.bind(this)); this.element.css(....) }; bubble.prototype.hide = function(){ $(document).off('click', this._click.bind(this)); this.element.css(....) }; bubble.prototype._click = function(event){ console.log('click', this); if(this.element.is(event.target) || (this.element.has(event.target).length...

jQuery - not unbinding events

jquery,bind
this ones a strange one. I have a plugin in which I store all the available event names in an array so when I destroy the instance I unbind all the bound events. I have picked out one event name just for an example. this.destroy = function( callback ){ //jqElm.off('hood.changed.customiser');...

How do I limit voucher's binding per transaction in Prestashop

bind,prestashop,cart
One of the prestashop's feature in cart pricing rules is the ability to bind different vouchers in one transaction. By default, you can bind 20 vouchers on a single transaction. The question is: How do I limit the vouchers per transaction as 10 vouchers only? Do I need to customize...

Pass in parameters for javascript click event

javascript,events,click,bind
I want to run a function within an object on click. In the object's init method, I bind a click to "runBFS". I use bind(this) to traversal so I can pass in the context of the object and not lose it to the window. var api = {}, api.init =...

How to add custom attributes to function callback Javascript

javascript,callback,bind
I have this code doPurchase = function(amount) { transactionCompleteCallbackImpl.bind(this, amount); iclient.initiatePurchase({ amount: amount, cashout: '0', integratedReceipt: true }, { statusMessageCallback: statusMessageCallbackImpl, questionCallback: questionCallbackImpl, receiptCallback: receiptCallbackImpl, transactionCompleteCallback: transactionCompleteCallbackImpl }); }; I do not control the iclient code as it is loaded from an external source, however I wish to add the...

boost asio custom allocator handler io service post compile errors

c++,templates,boost,bind,boost-asio
I have working io_service post call that looks as follows: _io_service.post(std::tr1::bind(&BlitzLogger::push,this, std::tr1::bind(&BlitzLogger::stringer<typename boost::decay<T const &>::type, typename boost::decay<Args const &>::type ...>, this, t, args ...))); I suspect the bind calls are having some overhead that can be done away with, so I proceeded to lay out the custom allocators for handlers...

Composite function with std::bind2nd in C++03

c++,bind,c++03
I would like to get some function/functor acts as a composite function/functor: Specifically, I have functions f(x, y), and g(u, v), and I want to create a function pointer or functor h(t) = f(g(t,C1), C2), so that I can pass functor h into a for_each() loop, where C1, C2 are...

org.jibx: maven-jibx-plugin:1.2.1 - Error reading path

apache,maven,plugins,bind,jibx
I am trying to execute a goal using maven-jibx-plugin version 1.2.1, but I am getting the following error: [ERROR] Failed to execute goal org.jibx:maven-jibx-plugin:1.2.1:bind (default) on project XoXcertExIm: Error loading class java.lang.CharSequence: Error reading path java/lang/CharSequence.class for class java.lang.CharSequence -> [Help 1] I am using Maven 3.2.5, Java versions 1.8.0_11,...

CakePHP behavior not working with bindModel

cakephp,model,controller,bind,behavior
I have a model named Users defined as: class User extends AppModel { ... public $actsAs = array( 'Date' => array('date_birth') ); ... The Date behavior converts the field date_birth from iso format ('yyyy-mm-dd') to locale format ('dd/mm/yyyy'). When from my controller I do a find such as $this->User->find(...) the...

Can anyone help me how to bind a variable in a String?

php,mysql,oracle,bind
Can someone help me in this problem. function get_shareSearch($conn, $searchBy) { $id = ""; if(isset($_GET['share'])) { $id = $_GET['share']; if($id == "%") { $id = "This is not going to work"; } } $statement = db_create_statement($conn, "SELECT DISTINCT * FROM shares WHERE company LIKE '%" . $id . "%' OR...

Observer Pattern Via Boost Signal2

c++,boost,signals,bind,observer-pattern
So, I've read the docs for Boost.Siganl2 and I have done a bit of Googleing and I just haven't quite found what I needed. What I have is a controller and a view concept. The Controller will be sending data to the View for it to render. What I want...

Awk to append out to array for further processing

arrays,bash,awk,bind
Hoping to pick your brains on something that my current bash skills is not able to compute;) Parsing a named.conf file for reference to filenames of actual zonefiles, that I would like to copy to a directory for migration purposes. First step, I had an idea about placing the paths...

Access to composer autoloaded files in laravel 5

laravel,instance,bind,autoload
Trying to use a non-Laravel package: https://packagist.org/packages/luceos/on-app Edited composer.json to require it and did the composer install, update, then dump-autoload -o. This package requires an initialization: vendor/luceos/on-app/src/OnAppInit.php Which isn't a class and only has the one method. But it doesn't seem to be loaded when I try to bind it...

variadic boost bind type resolution

c++,templates,bind,boost-asio,variadic-templates
I'm trying to write an async logger which accepts variadic arguments that are then strung together using a variadic stringer and then pushed onto a single producer single consumer queue. I'm stuck in my enqueue function part of my Log struct which looks as follows: template <typename T> std::string Log::stringer(T...

Bind 'this' variable from javascript 'String' function to another addon function

javascript,string,this,bind
I am trying to bind this function var addon = function(a){ if (typeof a == "string"){ return this+a; }else{ return this+String(a||""); } } To String.prototype.addon So that when I call "I".addon(" remember."); It returns "I remember." This is what I have for the String.prototype.addon so far. String.prototype.addon = addon.bind(); I...

Creation of a functor inside a member function without taking the class as a argument

c++,boost,bind,functor
Apologies for the cryptic decryption. I wish to create a functor of the following type: const boost::function<bool ()>& functor Please consider the class: #include <boost/function.hpp> class X { public: bool foo(); void bar() ; }; void X::bar() { const boost::function<bool (X *)>& f = &X::foo; } bool X::foo() { std::cout...

Dynamic binding of typeahead select event (jQuery)

javascript,jquery,bind,typeahead.js,selected
So I am currently creating a form that can be expanded dynamically. Each dynamically added row in the form contains an input field that displays suggestions using the jQuery typeahead plugin. I am trying to bind the typeahead:selected even to each new rows corresponding input field. The event returns the...

jquery click not binding even when using “.on” [duplicate]

jquery,click,bind
This question already has an answer here: Event binding on dynamically created elements? 8 answers This is something I've done 100 times, but I can't spot why it's not binding. I'm creating a itemized list from a TAFFY database. // get matching data from tfPLdata var ts=""; var match=0;...

ReactJS dynamic button bind

jquery,button,dynamic,reactjs,bind
Let's say the code (child component called Answers) generates 3 divs dynamically (based on dataset mapped) and each div contains a textbox and a submit button. If a user types something into the 2nd textbox and clicks submit, how do I maintain the proper binding (grab the text from the...

How to avoid bind(this) on every function?

javascript,bind
I'm implementing a web map client built on top of OpenLayers3 which should be able to connect to multiple WMS servers, ask for WMS Capabilities and show layers advertised by servers. var MyMapClient = function(params) { this.wms_sources_ = params.wms_sources; this.wms_capabilities_ = []; } MyMapClient.prototype.parse_capabilities = function(index) { var capabilities =...

Is it possible to detect if the object that a bound member function refers to is deleted or destroyed

c++,function,pointers,bind
I am exploring the use of std::function and std::bind. I see that you can bind a member function, for example: class A{ int c_ = 10; public: int add(int a, int b){ return a + b + c_; } }; int main(){ A* p_a = new A; std::function<int()> f =...

Binding to items in ItemsControl

c#,wpf,bind
I have problem with binding. My XAML structure in WPF looks like this: <ItemsControl ItemsSource="{Binding cacheList}" > <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding type}"/> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDown"> <i:InvokeCommandAction Command="{Binding loadFromCache}" CommandParameter="-- BIND TO CLICKED ITEM --"/> </i:EventTrigger>...

what is the purpose of binding and unbinding the same javascript function?

jquery,bind,unbind
I know what jquery bind() and unbind() does. But What is the purpose of binding and unbinding the same function using jquery function. In a large code base, I saw binding and binding a function in places. for ex. $('#someButtonID').unbind('click',functionName) .bind('click',functionName); What is the need of doing it?...

Angular Directive: bind 'mouseover' event to an element

javascript,angularjs,events,bind,directive
In my controller, I have the following array of users, which will be displayed by iteration in the partial html template in controller: vm.users = [ {"username": "johnDoe", "address": "Saltlake City, UT", "age": 34}, {"username": "janeDoe", "address": "Denver, CO", "age": 33}, {"username": "patrickDoe", "address": "San Francisco, CA", "age": 35} ];...

bind array from template to controller with angular

javascript,angularjs,data-binding,bind
Hi I have a problem with bind data from template to controller with angularjs The first I have object (edited) $scope.data = { } After that I bind it to html <input ng-model="data.item.test[0].value" /> But I controller I get { item: object() { 0: object() {value: "ok"} } } What...

Dynamic text with angular

html,angularjs,text,bind
I am trying to make a dynamic text that is edible only for some of it, and the non edible is from a database or variables. For example, if I have a variable kid's name = Adam, and my sentence is: 'Yesterday I was talking to Adam, He enjoyed the...

std::packaged_task with std::bind(func, this) within class

c++,c++11,bind,packaged-task
I have prepared a small snippet isolating my problem here. Here it is : #include <stdio.h> #include <future> #include <functional> class foo { public: foo(int a, int b) : m_a(a), m_b(b) {} int somefunc(int a, int b) { printf("foo w0w : %d, %d", a == m_a, b == m_b); return...

Number of bind variables doesn't match - sql insert

php,sql,variables,insert,bind
I'm getting: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in E:\XAMPP\htdocs\account\lib\register.php on line 73 When I use this code: if($stmt = $conn -> prepare("INSERT INTO login(user, pass) VALUES(?, ?)")) { /* Bind parameters s - string, b - blob, i - int, etc...

Linux local communication sockets: Why is bind() not failing as expected?

c,linux,sockets,bind
I have this server application that sets up a local communication stream socket for clients to connect to. If a second instance of the server is launched and it tries to bind to the same address (file name), bind() should fail with EADDRINUSE. But it does not. Why? Here is...

Binding Object Prototype Functions to Object in Javascript

javascript,prototype,call,this,bind
Background I have a prototype object that has dozens of functions that access info from a list like this: var prototype_object = { yellow: function(list) { return list[this.type+'_yellow']; }, green: function(list) { return list[this.type+'_green']; }, // ... 50 more functions here } The 'this.type' is supposed to come from the...

Why exactly binding a socket to multiple ports is not allowed?

sockets,port,bind
Why does this limitation exist? What is the technical reason for it? AFAIU, ports were introduced to distinguish between facilities (services, connections, etc.) of the same host, so logically the limitation is reasonable. However, SO_REUSEADDR exists to allow one-port-to-many-sockets binding, but not the other way round. It seems practical, because...

Can the type returned by std::bind be default-constructed?

c++,c++11,bind,typedef,default-constructor
I can typedef the return type of a std::bind expression, but apparently the compiler is not happy with me calling the default-constructor of this type. Instead, I have to pass the exact same arguments that I did to std::bind in the first place (cf below); why? Am I doing this...

Why requestAnimFrame need bind(this)

javascript,prototype,bind,requestanimationframe
Why does window.requestAnimFrame must be called like this: window.requestAnimFrame(this.__proto__.animate.bind(this)); and not like window.requestAnimFrame(this.__proto__.animate);. My js-class looks like: Game = function (moduleConfig, gameConfig) { this.moduleConfig = moduleConfig; this.gameConfig = gameConfig; // Game-Commands this.keyCommands = { moveLeft: false, moveRight: false }; // Some init stuff requestAnimFrame(this.animate.bind(this)); return this; } /** * Init...

How do I reuse an intermediate value in chain of Haskell Either binds?

haskell,binding,bind,chain
I'm sure this has been answered but apparently I don't know what to search for. I am working on my first non-trivial Haskell program -- a simulation of a card game I enjoy. I have the program working but there is a situation that I am certain can be handled...

JavaFX - how to synchronize scrollbars of two elements declared in FXML file

java,javafx,scrollbar,bind,fxml
I am developing IDE and I just stucked in the following problem: I want to create TabPane, load into some place in the program (to VBox), then add TAB on use some addFile hanler and BUILD TAB content by code_workspace.fxml file (That all is working for now). But I just...

Why I get a SOA dig response?

dns,bind,server
Some time ago I setup a site with some subdomains (example.com, test.example.com...) Last week I added a new subdomain new.example.com and today I've realize that when I dig to the secondary server I get the SOA record as a response, not the answer itself: [email protected]:~$ dig new.example.com @ns.kimsufi.com ; <<>>...

Using bind to change scope

javascript,jquery,bind
I would like to understand how bind is used to change the scope of the function that is executed when the result is returned. What is the .bind executed on exactly? Why would the .bind affect the scope of code that is executed within the function? Any help will be...

Integrate ElFinder with existing permission system

php,hook,bind,elfinder
Is there a way to integrate elfinder with my current user permissions system? I would need some kind of hook which would be triggered before e.g. a file gets deleted. There I should be able to abort the delete command and return some kind of response if the logged in...

How to bind delegated events within JavaScript for-loop

javascript,loops,events,for-loop,bind
I have an array of objects that I am looping over using a standard JavaScript for-loop. I am trying to use jQuery to create delegated events for each one of these objects while in the loop. Each object has an eventType property, which can be any custom event, and also...

Accessing original 'this' when using .bind()

javascript,scope,bind
I've just started using FUNCTION.bind(scope) instead of making a scope alias. I'm wondering if there is a way to access the original scope i.e. what this would have refered to so that I can use both of these scopes without creating a scope alias (var scope = this;) // Example...

Using PDO::FETCH_CLASS to bind table fields to object properties

php,pdo,bind
Using PDO::FETCH_CLASS to populate class fields with column values returned as a result of fetching database I wrote code like this one. <?php class Recipe { public $recipe_name; // works without declaring variable here public $chef_name; // works without declaring variable here public $num_ingredients; // works without declaring variable here...

how do i set up local bind server for dev machine to map to vhosts on server

linux,dns,bind,vhosts
im trying to set up a bind dns controller https://wiki.archlinux.org/index.php/BIND on an arch linux box. The main thing i need out of this is so i will no longer need to edit windows/system32/drivers/etc/hosts file again on my win7 dev box, and can delete every custom entry in it gone, and...