I have a grid which works normally while adding, removing, deleting rows.
Now, troubles come when I try to add row and then I click cancel. After that, my entire grid element loses .data('kendoGrid') (it returns undefined after that). I don't have any custom actions defined.
Did anyone run into similar issue?
I found the solution finally...
So, the problem was that I have been using grid like this:
<div class='n-grid' kendo-grid="widget" k-options="gridOptions"></div>
But this kind of using requires additional div wrapper. When I changed it to:
<div>
<div class='n-grid' kendo-grid="widget" k-options="gridOptions"></div>
</div>
Everything was fine...
I found this out from this part of angular-kendo.js:
self.bind("dataBinding", function(ev) {
ev.sender.$angular_itemsToCompile().each(function(){
var el = $(this);
if (el.attr(_UID_)) {
var rowScope = angular.element(this).scope();
// avoid destroying the widget's own scope
// no idea why we get it, but we do.... :(
if (rowScope && rowScope !== scope) {
destroyScope(rowScope, el);
}
}
});
When used without wrapper, cancelling changes in row, destroy parent's scope.
Hope this helps :)
Related
I'm using smart-table at the moment, and I have input text boxes up the top of each column and I am using st-search. The point of what I am making is something is selected from the table, and then the results in the table are changed.
I am trying to clear the search boxes when the row is clicked. At the moment other business logic is implemented on click, so it's at this point that I am looking to clear these text boxes.
I have tried to associate an ng-model to these text boxes, and to clear them when the row is clicked but the text boxes don't change. I have also googled this issue and I have only found solutions on how to make this work for when you click on a button (by a directive) to clear the predicates. I haven't been able to make these solutions work programatically however.
To resolve this I did the following:
Monkey-patched smarttable.js with the code in this github issue (https://github.com/lorenzofox3/Smart-Table/issues/164). For me this occured at around line 574.
// added from https://github.com/lorenzofox3/Smart-Table/issues/164
ng.module("smart-table").directive("stResetSearch",
function() {
return {
restrict: 'EA',
require: '^stTable',
link: function(scope, element, attrs, ctrl) {
return element.bind('click',
function() {
return scope.$apply(function() {
var tableState;
tableState = ctrl.tableState();
tableState.search.predicateObject = {};
tableState.pagination.start = 0;
return ctrl.pipe();
});
});
}
};
});
Added 'st-research-search' to the element that was calling the function in angularjs. For me, that was the "tr" element. Like below.
<tr ng-repeat="medicine in medicines" ng-click="medicationMatched(medicine)" ng-class="heatmapClass(medicine)" st-reset-search>
This worked fine. Unfortunately, I wasn't able to programatically clear the predicates from the code. But this works well enough for me.
Is there any event that is fired when there is a change inside custom div?I don't want to listen for editor.on('change'), but only to detect in which dom element the change is taking place, (removed or inserted character). For example:
var template = new CKEDITOR.template(
'<div class="layout-container">\
<div class="layout-column-content" >\
<p>content</p>\
</div>\
</div>\
</div>\
</div>'
);
var layoutElement = CKEDITOR.dom.element.createFromHtml(template);
editor.insertElement(layoutElement);
Adds custom layout.User types in it and i want to see what is he typing without traversing the whole dom. I tried to add listeners to the div but it seems that CKEditor cleans them. Any clever solutions?
Edit:
This plugin http://ckeditor.com/addon/elementspath is probable workaround:
i have solved my problem with this snippet:
editor.on('elementsPathUpdate', function(event) {
elementsList = editor._.elementsPath.list;
});
combined with the change event.
The only solution i know is this plugin: http://alfonsoml.blogspot.de/2011/03/onchange-event-for-ckeditor.html
Looks like the ModalTrigger doesn't play well when being supplied a React component. Consider the following:
var MyDiv = React.createClass({
render : function() {
return <div>Click me!</div>
}
});
var Content = React.createClass({
render : function() {
return <div>
<ModalTrigger modal={<MyModal/>}>
<MyDiv/>
</ModalTrigger>
<ModalTrigger modal={<MyModal/>}>
<div>No, click me!</div>
</ModalTrigger>
</div>
}
});
React.render(<Content/>, document.getElementById("mydiv"));
When clicking on the first div, nothing happens, but the second div opens the modal as expected.
The DOM looks identical, but when using the React extension for Chrome I can see that there is an additional React component between the first ModalTrigger and the underlying div, named MyDiv.
The reason this is a problem is that ModalTrigger depends on its child element onClick to show the modal. When using a regular div it works as expected, but since the direct child here is a React component, there is no obvious way to make this connection go to the actual div component.
So my question, is this a shortcoming of react-bootstrap that cannot deal with the way React instantiates components, or is this the normal / expected behavior that I should work around somehow?
Thanks!
Edit:
I wanted to post this as a comment but could not format it properly :/
One way of getting around this is to have MyDiv aware that it has a this.props.onClick method, and trigger it explicitly:
var MyDiv = React.createClass({
render : function() {
return <div onClick={this.props.onClick>Click me!</div>
}
});
This creates coupling (or extra lines for PropTypes/getDefaultProps to decouple), which is far from ideal.
Another way is to wrap MyDiv in another anonymous div:
<ModalTrigger modal={<MyModal/>}>
<div><MyDiv/></div>
</ModalTrigger>
Which is much better, but somehow doesn't feel right either. Any suggestions?
It seems that the answer is under the MyDiv's responsibility, at least in how react-bootstrap works. The magic happens when the top-level div in MyDiv is passed the props, like so:
var MyDiv = React.createClass({
render : function() {
return <div {...this.props}>Click me!</div>
}
});
This is both in step with react-bootstrap's inner components' behavior, and allows MyDiv to remain agnostic of whatever is passed through. It's probably better, as Facebook suggests, to use the harmony destructuring syntax (e.g., var {myProp, ...otherProps} = this.props and then using it in <MyDiv {...otherProps}/>), but, well... harmony.
Currently I have a page which on load scatters draggable divs randomly over a page using math.random
Using media queries however the page uses packery to display the same images for browser widths under 769px in a grided fashion.
I had the idea that it could be interesting to create a 'sort/organize' button which would rearrange these divs using packery and remove the draggable class already applied, however i have no idea if this is possible or how to go about it. If there is any method of animating this process that would also be a bonus!
If anyone could at the very least point me in the right direction i would be extremely thankful!!
Hopefully this gives you a bit of a starting point.
I would read up on JQuery as it has some useful helpers for DOM manipulation.
I don't think this is the most efficient way to do it, and I think you will need to rethink your test harness for doing this in the future, but hopefully this gets you started.
Firstly I've added a button to trigger the sort
<div class="rotate" id="contact">Contact</div>
<div id="logo">Andrew Ireland</div>
<button id="sort">sort</button>
Then updated the script to override the css setting to switch between draggable view and item view.
// general wait for jquery syntax
$(function(){
// trigger the layour to sort get the packery container
var container = document.querySelector('#container.packery');
var pckry = new Packery( container );
//button function
$("#sort").click(function(){
//Hide all the dragged divs
//ui-helper-hidden is a jquery ui hider class
if($('.box').css('display') == 'block') {
$('.box').css({'display':'none'});
//Show all the item class's
$('.item').css({'display':'block'});
//show the container
$('#container').css({'display':'block'});
// trigger the layour to sort
pckry.layout();
} else {
//hide all the item class's
$('.item').css({'display':'none'});
//hide the container
$('#container').css({'display':'none'});
//show the draggable box's
$('.box').css({'display':'block'});
}
});
$( ".pstn" ).draggable({ scroll: false });
$(".pstn").each(function(i,el){
var tLeft = Math.floor(Math.random()*1000),
tTop = Math.floor(Math.random()*1000);
$(el).css({position:'absolute', left: tLeft, top: tTop});
});
});
As I said this is more to get started. The packery documentation details how to trigger its layout functions so another approach would be to only have the draggable elements, and put these inside a packery container. Then when you want to sort them you can just trigger that the packery.layout() function.
I hope this is helpful, I am only just getting started on stack overflow so any feedback would be appreciated.
I am using the following code to direct the results from a form to a specific div.
$(window).load(function () {
$("#form1").submit(function() {
$.post($(this).attr("action"), $(this).serialize(), function(html) {
$("#resultsDiv").html(html);
});
return false; // prevent normal submit
});
});
How can I apply this (or any) handler to future forms that may be created within an updated div ( with new yet to created content inserted into the div at some point in the future)?
I have looked at the .on but I do not see an event for the updating or reloading of a div.
I have tried adding a similar function to the above, but replacing (window) with ("#thefutureDivID"), but no luck.
The best place to add the handler is right after you know the element exists. So, right after this line:
$("#resultsDiv").html(html);
you can add your code that references $("#thefutureDivID").