blikblum/tinybind

error patch fix on event catching

Opened this issue · 7 comments

I had to patch some code....... I added a try catch statement and rooted it to a model function..... just add a call function and you get the event.....
without the call function in the model you make it works as normal.... like it dose currently...
it has to do with clicks and key-pres events ... tinybind ignores it ....yet it can now be rooted back to you with this patch code...... its also a cool way ... your not adding document add event......
li tag with an input you click and it send you a call tiny bind ignores it ...why because its not part of binding yet it is..... ohhh now you can set style or get index and to get it you have do it the old way. .... like user hits a tree node you want to expand.... you get the index this way and can reset the styles.... anyway it should work grate and admin needs to understand it... as a new feature to not mess it up.... we connect code to this event call..... it ignores...... a call stack ....and its usefully. it binds only its job is done...
its slush events..

image

add this to your nodel you made.... with code above at line 130 codes in tinybind..... test it
call(context, ev, binding){
alert("Slush event");
},

ahhh may not work that grate unless admin thinks about it......
when working on a long list to get a click call you need to add....
rv-on-click="call" ---- to each Tag 5000 items ......
if you pass the call to a modal call event..... your HTML code shrinks
you simply run a switch statement on the call.....
like for tables and cells <---- HTML grows but not with a call....
tinybind i did my part here is the event and reference ....
a simple switch statement .......

in configuration you set this up.. on click send calls to mode...function
on mouse over send calls to mode...function
add custom event handler .to tinybind..... on swipe- long
if i add the java-script lib yet added the event to tinybind to register it.....
the even fires pass it to tiny bind and i get the binding data object back.....
if i added the event to dom i get no binding reference back... i just get the element

like on drag and drop i grab the event bind object and drop it you do nothing but pass the binding event references. to the model function...

two templates 2 different models yet i can run drag and drop this way......
master model and 2 slaves with registered event to tiny-bind one drag the other drop

move model event data to modal.push() and remove.....

i still have lots to lean on how the code is setup..... i just started testing it....

if admin wants to speed up tinybind and shrink the code down
you remove text binding phrasing
{item.gogo}
you now use a label tag or span or li in a p tag
dom calls are faster then text phrasing
tinybind register the event rooter for the model
window.onclick =function()
tinybind simple registers 1 event then binds to any model
try catch statement with switch statements bind and root
document.querySelector('input') <-on change of an array of elements
then send to....
model.onChange(event,data)
run validation code
model.onclick(event,data)
add your code.... styles or actions
model.onDarg(event,data)
tag the element for a dag
add your code
model2.onDrop(event,data)
now code------ model 1 wants to send data to model 2...
model2.domLoaded(event,data)

tinbind should not replace JavaScript like for if or show or hide

when you root events to models ...it changes everything your templates shrink... your JavaScript are now nested in the model
and tinybind ran two way binding for you eliminating tones of code at model level.

testing validation of an input event
i used this tag input rv-on-change="call"
i root all event calls to one function <----a simple way it always a call
call(context, ev){
switch (context.type) {
case "drag":
console.log("drag")
break;
case "change":
/////validation
console.log("change")
break;
}
},
if i need to process more i send it to an out side script of the container not in the container... keeping the model script small for cloning
All an all... tinybind works grate its doing what i need done....
i left the try catch in only because with debug it flagged a slush event error
i blog in test steps

how about a template events function to reduce code.......
basically a new attribute rv-template-on-click

divElem.setAttribute("rv-template-on-click","call");
divElem.setAttribute("rv-template-on-change","call");
divElem.setAttribute("rv-template-on-scroll","call-scroll");

like a very long list or table......
li input rv-on-click="call" <---too many events to add

we can get the event.target <------as the element that click it then package the correct binding node from its key path from <input rv-value="item.name" and send it to the call function

a global template event handler for all your elements i one shot..
old way
input rv-on-click="call" rv-on-click="focus" rv-on-dbclick="call" rv-value="item.name"
now its nice looking like this
input rv-value="item.name"

like for a table array 100 x 30 too many attributes to add.... for each element
let dom do the work for you

config <---- no text phrasing just element binding use label element

i would strip it out why.. simple text can run a function...... where you should have the element govern bindings

wow..... implements validation some miner code to tinybind for new event handler.....
this for new type of template events
divElem.setAttribute("rv-template-on-click","call");
divElem.setAttribute("rv-template-on-change","call");
global event handler for template to run validation to your model....
== all clicks are sent to you and the user entered the input==
image
=== next is validating because i know what the value is before editing yellow to store====

image

As you can see the user changed it and left yet i hold the original value i can put back....
it has to done with a template attribute so you can let tiny do its job with its events....
rv-on-click <---- one to one and
rv-template-on-click <- one to many under one even registry with tiny bind
1000 elements all need to be registered in a list ...... not any more....

@julientype glad to see this perhaps a fork repo and a use case to review would be best here as it could be an interesting development.

Feel free to share more with examples.